我用下面的代码创建了一个矩形,现在我需要圆这个矩形的角。但是我找不到一个叫做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
}
}
6条答案
按热度按时间klsxnrf11#
您可以使用下面的方法来使所有的角落圆的看法...
如果你想把特定的角落弄圆,就用下面的方法。
eqfvzcg82#
这样使用:
对于“所有拐角半径”,编辑此
j0pj023g3#
使用此初始化器
或
r8xiu3jd4#
目标c:
SWIFT:
希望这会有所帮助。
wbrvyc0a5#
就像这样简单:
nfeuvbwi6#
如果要使矩形的角变圆,可以使用
但是如果你想把它们做成椭圆形,你就做不到。这是因为UIBezierPath忽略了cornerRadiii.height。我在我的实现中修复了它。
https://github.com/BuTaJIuK-ua/UIBezierPath-Extension