我想设置一个UIView动画,但不是花了一段时间,我想控制百分比进度,让它自动为我插值.那可能吗?谢谢
解决方法
我想我已经明白了.在[UIView animate …]块之后,立即在根视图上执行以下操作:
_view.layer.speed = 0.0; _view.layer.timeOffset = [_view.layer convertTime:CACurrentMediaTime() fromLayer:nil];
要在比例上设置点,请执行以下操作:
_view.layer.timeOffset = 0..1; (where 1 is the same value as the original duration)
并恢复,类似于以下内容:
CALayer *layer = _view.layer; CFTimeInterval pausedTime = [layer timeOffset]; layer.speed = 1.0; layer.timeOffset = 0.0; layer.beginTime = 0.0; CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime; layer.beginTime = timeSincePause;
这一切都来自这里:https://developer.apple.com/library/ios/qa/qa1673/_index.html