【发布时间】:2017-11-08 17:02:09
【问题描述】:
我已经尝试了所有可能的语法变化,但完成处理程序总是在动画结束之前激活。我想我应该用别的东西代替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
})
【问题讨论】:
-
是否立即调用完成闭包?
-
你在运行其他动画吗?
Bool将告诉您动画是否已取消或未完成 (false),或者是否成功完成 (true)。见:stackoverflow.com/questions/8686922/… -
您在屏幕上实际看到了什么以及您期望什么?
-
根据描述,我怀疑目标是让指标逐渐淡出(alpha 为 0),1 秒后,指标被合法隐藏。这里的说法是该指标立即被隐藏(即没有褪色)。
-
也就是说,我认为您实际上可能想要使用动画方法而不是过渡方法。
标签: ios swift syntax swift4 completionhandler