快速转角半径问题
let path = UIBezierPath(roundedRect:username.bounds, byRoundingCorners:[.TopRight, .BottomLeft], cornerRadii: CGSizeMake(20, 20))
let maskLayer = CAShapeLayer()
maskLayer.path = path.CGPath
username.layer.mask = maskLayer
答案 0 :(得分:0)
如果您将视图子类化为您想要提供的角落,则可以这样做:
override func layoutSubviews() {
super.layoutSubviews()
maskLayer.frame = self.bounds
maskLayer.path = UIBezierPath(roundedRect: bounds, byRoundingCorners: UIRectCorner.topLeft.union(.topRight), cornerRadii: CGSize(width: 25, height: 25)).cgPath
self.layer.mask = maskLayer
}