3
我使用UIBezierPath通过分数相加点装箱矩形绘制矩形,现在我要四舍五入这个矩形的角落,但似乎没有办法做到这一点。谁能帮我 ?如何圆润边角,当我使用UIBezierPath点
class RectangleLayer: CAShapeLayer {
let animationDuration: CFTimeInterval = 0.5
override init() {
super.init()
fillColor = Colors.clear.CGColor
lineWidth = 5.0
path = rectanglePathStart.CGPath
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var rectanglePathStart: UIBezierPath {
let rectanglePath = UIBezierPath()
rectanglePath.moveToPoint(CGPoint(x: 0.0, y: 100.0))
rectanglePath.addLineToPoint(CGPoint(x: 0.0, y: -lineWidth))
rectanglePath.addLineToPoint(CGPoint(x: 100.0, y: -lineWidth))
rectanglePath.addLineToPoint(CGPoint(x: 100.0, y: 100.0))
rectanglePath.addLineToPoint(CGPoint(x: -lineWidth/2, y: 100.0))
rectanglePath.closePath()
// fillColor = Colors.red.CGColor
return rectanglePath
}
}
你可以使用'bezierPathWithArcCenter:radius:startAngle:endAng le:顺时针方向:'为你想要的每个角落。 – Larme