Currently we have a circular progress bar that is working properly, for testing purposes it is activated by a tap gesture.
func createCircleShapeLayer() {
let center = view.center
if UIDevice.current.userInterfaceIdiom == .pad {
let circlePath = UIBezierPath(arcCenter: center, radius: 150, startAngle: -CGFloat.pi / 2, endAngle: 2 * CGFloat.pi, clockwise: true)
circleShapeLayer.path = circlePath.cgPath
} else {
let circlePath = UIBezierPath(arcCenter: center, radius: 100, startAngle: -CGFloat.pi / 2, endAngle: 2 * CGFloat.pi, clockwise: true)
circleShapeLayer.path = circlePath.cgPath
}
circleShapeLayer.strokeColor = UIColor.green.cgColor
circleShapeLayer.lineWidth = 20
circleShapeLayer.fillColor = UIColor.clear.cgColor
circleShapeLayer.lineCap = CAShapeLayerLineCap.round
circleShapeLayer.strokeEnd = 0
view.layer.addSublayer(circleShapeLayer)
//tap gesture used for animation testing
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(anitmateCirleProgress)))
}
@objc func anitmateCirleProgress() {
let strokeAnimation = CABasicAnimation(keyPath: strokeEnd)
strokeAnimation.toValue = 1
strokeAnimation.duration = 2
strokeAnimation.fillMode = .forwards
strokeAnimation.isRemovedOnCompletion = false
circleShapeLayer.add(strokeAnimation, forKey: "strokeAnimation")
}
The issue is that the progress bar has to be able to fill based on the status of a UIProgressView: ex.
totalProgressView.setProgress(45, animated: true)
Is there a way to sync the animation stroke based on the progress of the UIProgressView?