如何为UIBezierPath提供cornerRadius [英] How to give cornerRadius for UIBezierPath
本文介绍了如何为UIBezierPath提供cornerRadius的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下代码创建了一个矩形,现在我需要对此矩形的角进行舍入。但我找不到名为layer.cornerRadius的属性,有人可以帮助我吗?
I created a rectangle using following code and now I need to rounded the corners of this rectangle. but I can't find a property called layer.cornerRadius, can anyone help me ?
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
}
}
推荐答案
你可以使用以下方法进行所有角落视图...
You can use below method to make all corner round of view...
UIBezierPath(roundedRect: anyView.bounds, cornerRadius: CGSize(width: 10.0, height: 10.0))
如果你想要特定的角落圆形使用以下方法。
If you want particular corner to make round use below method.
UIBezierPath(roundedRect: anyView.bounds,
byRoundingCorners: .BottomLeft | .BottomRight,
cornerRadius: CGSize(width: 10.0, height: 10.0))
这篇关于如何为UIBezierPath提供cornerRadius的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文