最后,我使用
UIView.animateKeyFrames
将交互式过渡划分为两部分动画(如问题中所述):
let progressUntilDismissing = 0.4
UIView.animateKeyframes(withDuration: 0.5, delay: 0, options: [], animations: {
UIView.addKeyframe(withRelativeStartTime: 0.0,
relativeDuration: progressUntilDismissing,
animations: {
// interactive dismissing animation...
})
UIView.addKeyframe(withRelativeStartTime: progressUntilDismissing,
relativeDuration: (1 - progressUntilDismissing),
animations: {
// closing dismissing animation...
})
}) { (finished) in
//...
}
然后在平移手势识别器中,我计算平移进度并确定是否通过
progressUntilDismissing
或者不是。
如果是,请致电
finish()
在…上
UIPercentDrivenInteractiveTransition
子类,它将自动设置关闭解除动画的动画。
如果有人好奇,这就是我在玩的游戏:
AppStoreTodayInteractiveTransition