First, CashapelayerCashapelayer is a subclass of Calayer, but more flexible than calayer, you can draw a variety of shapes using Cashapelayer to draw a rectangle
let layer = CAShapeLayer()
layer.frame = CGRectMake(110, 100, 150, 100)
layer.backgroundColor = UIColor.blackColor().CGColor
view.layer.addSublayer(layer)
CAShapeLayer 画图时的动画改变
Strokeend, Strokestart, and LineWidth are three properties that control the animation effect when the dash is crossed.
Two
Uibezierpath
Cashapelayer has a magical attribute that path uses this property in conjunction with the Uibezierpath class to achieve the super-divine effect.
2.1. Two important color properties of Cashapelayer
fillcolor: fill Color of Layer
layer.fillColor = UIColor.clearColor().
CGColor
strokecolor:layer Border Color
layer.strokeColor = UIColor.blackColor().CGColor
2.2、CAShapeLayer 和
Uibezierpath Mating Line
let path = UIBezierPath(arcCenter: view.center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise:
true
)
let layer = CAShapeLayer()
layer.path = path.CGPath
layer.fillColor = UIColor.clearColor().CGColor
layer.strokeColor = UIColor.blackColor().CGColor
Uibezierpath and Cashapelayer with wanton drawing