【发布时间】:2017-01-31 20:20:22
【问题描述】:
这是通过UI扩展方法
extension UIView {
func roundCorners(corners:UIRectCorner, radiusWidth: CGFloat,radiusHeight: CGFloat) {
let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radiusWidth/2, height: radiusHeight/2))
let mask = CAShapeLayer()
mask.path = path.cgPath
self.layer.mask = mask
}}
通过这种扩展方法,我想在 viewdidload 上使用此代码制作带圆角的按钮
btnRideNow.roundCorners(corners: [.topRight], radiusWidth: btnRideNow.frame.width,radiusHeight: btnRideNow.frame.height )
btnRideLater.roundCorners(corners: [.topLeft], radiusWidth: btnRideLater.frame.width,radiusHeight: btnRideLater.frame.height )
但在 iPhone 5 上我得到了这个结果 ScreenShot
您可以看到左键无法正确呈现,但在 iPhone 6 中却可以正常显示,为什么?
【问题讨论】: