我使用下面的代碼創建了一個矩形,現在我需要四捨五入矩形的角。但我找不到名爲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