1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
let myView = UIView() //UIBezierPath的构造函数参数
let maskPath = UIBezierPath(roundedRect: myView.bounds, byRoundingCorners: [UIRectCorner.topRight, UIRectCorner.topLeft], cornerRadii: CGSize(width: 8, height: 8))
let maskLayer = CAShapeLayer()
maskLayer.frame = myView.bounds
maskLayer.path = maskPath.cgPath
myView.layer.mask = maskLayer
view.addSubview(myView)
|
近期评论