是否有办法知道Lottie animation
何时完成?我需要delete
一个tableViewCell
,但仅在animation
完成之后。这是animation
:
设置:
//MARK: setup Loading-Animation
func setupLoadingAnimation(){
successAnimation.translatesAutoresizingMaskIntoConstraints = false
self.contentView.addSubview(successAnimation)
successAnimation.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: -30).isActive = true
successAnimation.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true
successAnimation.widthAnchor.constraint(equalToConstant: 160).isActive = true
successAnimation.heightAnchor.constraint(equalToConstant: 160).isActive = true
successAnimation.isHidden = true
successAnimation.loopMode = .playOnce
}
动作:
@objc func checkButtonTapped(){
self.deleteWishCallback?()
self.successAnimation.isHidden = false
self.successAnimation.play()
}
我想实现的是能够在self.deleteWishCallback?()
的结尾处调用self.successAnimation.play()
。有没有办法做到这一点?找不到任何东西!
Lottie动画基本播放
AnimationView.play(完成:LottieCompletionBlock?)
从当前状态播放动画到其时间轴的结尾。动画停止时调用完成块。
参数::完成:动画完成时调用的完成块。如果动画完成,将通过true传递块;如果动画被中断,则将传递false块。可选。
示例:
starAnimationView.play { (finished) in
// Animation finished
//here if finised is true you can perform the action of deleting the tableviewCell
}
您可以在https://airbnb.io/lottie/#/ios?id=enabling-and-disabling-animation-nodes中找到更多信息