我最近发现我的一个动画不起作用了
//time is a variable used in my code
UIView.animate(withDuration: time, delay: 0, options: [.curveLinear, .allowUserInteraction], animations: {
//this class is ofType UIScrollView
self.setContentOffset(CGPoint(x: self.contentSize.width-self.frame.width, y: 0), animated: false)
//Completion Handler
}, completion: { finished in
//It's always true, not sure a way to fix this
if(finished ) {
但是,在我的代码中稍后,我有一个方法来移除特定的动画,具体来说是从这个scrollView中移除。
self.layer.removeAllAnimations()
它被调用了,我想它应该是为了使上述内容生效。
if(finished ) { //Here
return false,因此它不应该进入finished。但是,finished总是为true。无论我取消这个动画,继续这个动画,不管我对动画做什么,完成处理程序始终为true。请问有关此事的任何提示吗?