我saw a lot的answers關於此topic,但無法解決我的特殊情況。CABasicAnimation animationDidStart確實打過電話,但是animationDidStop從來不是
Here is a video with complete animation and logging timeline
class AnimationDelegate: UIView {
deinit {
print("AnimationDelegate deinitialized")
}
override func animationDidStart(anim: CAAnimation) {
print("animationDidStart")
}
override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
print("animationDidStop")
}
func play() {
let line_1 = CAShapeLayer()
...
let animation = CABasicAnimation()
animation.delegate = self
animation.duration = 3000
animation.repeatCount = 1
animation.keyPath = "strokeEnd"
animation.fromValue = 0
animation.toValue = 360
layer.addSublayer(line_1)
line_1.addAnimation(animation, forKey: "StrokeAnimation")
}
}
let delegate = AnimationDelegate(frame: container.bounds)
container.addSubview(delegate)
delegate.play()
問題是animationDidStart
調用,但animationDidStop
沒有。
這怎麼可能?
編輯您的問題以包含配置「CABasicAnimation」的代碼。 –
@ rob-mayoff感謝您的要求。我做完。 – George