我已尝试过每种语法变体,但完成处理程序始终在动画结束前激活。我想我应该用其他东西替换Bool
?
UIView.transition(with: swipeForPicturesIndicator,
duration: 1,
options: .curveEaseIn,
animations: {
self.swipeForPicturesIndicator.alpha = 0
},
completion: { (Bool) -> Void in
self.swipeForPicturesIndicator.isHidden = true
self.swipeForPicturesIndicator.alpha = 0.8
})
答案 0 :(得分:1)
Bool
值表示调用完成块时动画完成。如果该值为false
,则表示您的动画已中断。
您应该使用animate
代替transition
UIView.animate(withDuration: 1,
delay: 0,
options: .curveEaseIn,
animations: {
self.swipeForPicturesIndicator.alpha = 0
}) { (completed) in
/* Optionally check if animation finished */
self.swipeForPicturesIndicator.isHidden = true
self.swipeForPicturesIndicator.alpha = 0.8
}
答案 1 :(得分:0)
试试这个
self.swipeForPicturesIndicator.alpha = 0
UIView.transition(with: swipeForPicturesIndicator,
duration: 1,
options: .curveEaseIn,
animations: {
self.swipeForPicturesIndicator.alpha = 0.8
},
completion: nil)
答案 2 :(得分:0)
您可能希望使用动画而不是过渡:
UIView.animate(withDuration: 1, delay: 0, options: .curveEaseIn, animations: {
self.swipeForPicturesIndicator.alpha = 0
}) { (success) in
self.swipeForPicturesIndicator.isHidden = true
self.swipeForPicturesIndicator.alpha = 0.8
}