Problem
I create the effect of exploding rings. I use several CAShapeLayer and create a UIBezierPath for each layer. When the view is initialized, all layers have a path with a width of 0 . When the action starts, the rings expect a larger path.
As you can see from the demo below, the right edge of each layer is slower to animate than the rest of each circular layer.
Demo

The code
Drawing layers:
func draw(inView view: UIView) -> CAShapeLayer { let shapeLayer = CAShapeLayer() // size.width defaults to 0 let circlePath = UIBezierPath(arcCenter: view.center, radius: size.width / 2, startAngle: 0, endAngle: CGFloat(360.0).toRadians(), clockwise: true) shapeLayer.path = circlePath.CGPath shapeLayer.frame = view.frame return shapeLayer }
Layer update
func updateAnimated(updatedOpacity: CGFloat, updatedSize: CGSize, duration: CGFloat) { let updatePath = UIBezierPath(arcCenter: view.center, radius: updatedSize.width / 2, startAngle: 0, endAngle: CGFloat(360).toRadians(), clockwise: true) let pathAnimation = CABasicAnimation(keyPath: "path") pathAnimation.fromValue = layer.path
ios swift uibezierpath cashapelayer
Ollie
source share