我试图绕过UIView上左下角和右下角。


extension UIView {
func roundBottom(raduis: CGFloat){
let maskPath1 = UIBezierPath(roundedRect: bounds,
byRoundingCorners: [.BottomRight, .BottomLeft],
cornerRadii: CGSize(width: raduis, height: raduis))
let maskLayer1 = CAShapeLayer()
maskLayer1.frame = bounds
maskLayer1.path = maskPath1.CGPath
layer.mask = maskLayer1
}
}打电话给cell.bottomCorner.roundBottom(8)
,但我明白了:
iPhone 5:

iPhone 6s:

iPhone 6s Plus:

发布于 2018-11-01 11:41:41
每次视图更改其大小时,都必须更新掩码,因此,理想情况下,无论何时调用UIView.layoutSubviews,都应该更改它:
override func layoutSubviews() {
super.layoutSubviews();
// update mask
}在扩展助手方法中这样做并不理想。您应该创建一个特定的类来处理大小更改。
https://stackoverflow.com/questions/53100445
复制相似问题