Swift 中 Lottie 动画的闭包函数
Closure function with Lottie Animation in Swift
有没有办法知道 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.successAnimation.play()
的闭包中调用self.deleteWishCallback?()
。有没有办法完成这项工作?在此找不到任何内容!
Lottie动画基础播放
AnimationView.play(completion: LottieCompletionBlock?)
从当前状态播放动画到时间线结束。动画停止时调用完成块。
参数::完成:动画完成时调用的完成块。如果动画完成,块将被传递 true,如果动画被中断,块将被传递 false。可选。
示例:
starAnimationView.play { (finished) in
// Animation finished
//here if finised is true you can perform the action of deleting the tableviewCell
}
你可以找到更多HERE
有没有办法知道 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.successAnimation.play()
的闭包中调用self.deleteWishCallback?()
。有没有办法完成这项工作?在此找不到任何内容!
Lottie动画基础播放
AnimationView.play(completion: LottieCompletionBlock?)
从当前状态播放动画到时间线结束。动画停止时调用完成块。
参数::完成:动画完成时调用的完成块。如果动画完成,块将被传递 true,如果动画被中断,块将被传递 false。可选。
示例:
starAnimationView.play { (finished) in
// Animation finished
//here if finised is true you can perform the action of deleting the tableviewCell
}
你可以找到更多HERE