我使用以下代码创建了一个矩形,现在我需要圆化该矩形的角。但我找不到名为layer.cornerRadius的属性,有人可以帮助我吗?
class OvalLayer: CAShapeLayer {
let animationDuration: CFTimeInterval = 0.3
override init() {
super.init()
fillColor = Colors.green.CGColor
path = ovalPathSmall.CGPath
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var ovalPathStart: UIBezierPath {
let path = UIBezierPath(ovalInRect: CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0))
return path
}
}
您可以使用以下方法使所有角落都变成圆形视图...
UIBezierPath(roundedRect: anyView.bounds, cornerRadius: CGSize(width: 10.0, height: 10.0))
如果您想要将特定的角制成圆形,请使用以下方法。
UIBezierPath(roundedRect: anyView.bounds,
byRoundingCorners: .BottomLeft | .BottomRight,
cornerRadius: CGSize(width: 10.0, height: 10.0))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)