My code below needs to hide a shapeLayer. Right now it removes that color that animates it but its border is still there. My problem can be fond in ////WHAT I AM TRYING IS NOT WORKING.the issue is obviously the tracking layer I dont know how to hide that .
let shapeLayer = CAShapeLayer()
@objc func action(){
time += 1
lzbel.text = String(time)
if time == 60 {
timer.invalidate()
lzbel.isHidden = true
enterText.isHidden = false
enterScore.isHidden = false
resetbtn.isHidden = false
scores.isHidden = false
////WHAT I AM TRYING IS NOT WORKING
shapeLayer.removeAllAnimations()
shapeLayer.removeFromSuperlayer()
}
if time == 0 {
izmge.image = UIImage(named:"art.png")
lzbel.isHidden = true
let center = CGPoint(x:view.center.x,y:view.center.y + 150)
let trackLayer = CAShapeLayer()
let circularPath = UIBezierPath(arcCenter: center, radius: 100, startAngle: -CGFloat.pi / 2, endAngle: 2 * CGFloat.pi, clockwise: true)
trackLayer.path = circularPath.cgPath
trackLayer.strokeColor = UIColor.lightGray.cgColor
trackLayer.lineWidth = 10
trackLayer.fillColor = UIColor.clear.cgColor
trackLayer.lineCap = kCALineCapRound
view.layer.addSublayer(trackLayer)
shapeLayer.path = circularPath.cgPath
shapeLayer.strokeColor = UIColor.red.cgColor
shapeLayer.lineWidth = 10
shapeLayer.fillColor = UIColor.clear.cgColor
shapeLayer.lineCap = kCALineCapRound
shapeLayer.strokeEnd = 0
let basicAnimation = CABasicAnimation(keyPath: "strokeEnd")
basicAnimation.toValue = 0.8
basicAnimation.duration = 60
basicAnimation.fillMode = kCAFillModeForwards
basicAnimation.isRemovedOnCompletion = false
shapeLayer.add(basicAnimation, forKey: "urSoBasice")
view.layer.addSublayer(shapeLayer)
}}