我使用下面的代码创建了一个矩形,现在我需要四舍五入矩形的角。但我找不到名为layer.cornerRadius的属性,任何人都可以帮助我?如何给UIBezierPath的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
}
}
u可以使用UIBezierPath本身而绘制,使圆角半径 – vaibby
由于您使用** UIBezierPath **您只需使用UIBezierPath绘制圆角。检查[this](http://ronnqvi.st/thinking-like-a-bzier-path/),它会帮助你解决所需的问题。 – iphonic