如何在iOS中创建图像的倾斜视图

时间:2019-05-20 11:56:52

标签: ios swift uiimage ios-autolayout

如何创建像下面图像一样的倾斜视图。

enter image description here

请给我一个解决方案。我尝试了很多方法,但没有找到合适的解决方案。

private let kTableHeaderHeight: CGFloat = 400.0 
private let kTableHeaderCutAway: CGFloat = 60.0 
var headerRect = CGRect(x: 0, y: -effectiveHeight, width: self.view.bounds.width, height: kTableHeaderHeight)
headerRect.size.height = kTableHeaderCutAway/2 
headerView1.frame = headerRect 
let path = UIBezierPath() path.move(to: CGPoint(x: 0, y: 0)) 
path.addLine(to: CGPoint(x: headerRect.width, y: 0))
path.addLine(to: CGPoint(x: headerRect.width, y: headerRect.height))
path.addLine(to: CGPoint(x: 0, y: headerRect.height-kTableHeaderCutAway)) 
headerMaskLayer?.path = path.cgPath headerView1.layer.mask = headerMaskLayer [1]: 

0 个答案:

没有答案