我目前正在创建一个加载栏,如果采取了特定操作,我想暂停并反转它。
我在下面有以下代码,可以在另一个 View 中设置一个 View 。我将如何暂停此动画并在动画对象的那个时间点在当前帧上应用另一个动画。我希望能够在当前动画中的任何给定时间将此条动画化到 0 宽度标记。
-(void)animateProgressBar
{
CGRect endingFrame = self.frame;
[UIView animateKeyframesWithDuration:self.time delay:0.0 options:0 animations:^{
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:1.0 animations:^{
self.loadingBar.frame = endingFrame;
}];
} completion:^(BOOL finished) {
NSLog(@"TADA");
}];
}
最佳答案
如果你想从现在的位置开始一个新的动画,只需使用 UIViewKeyframeAnimationOptionBeginFromCurrentState
开始新的动画。选项(或者如果只是做 animateWithDuration
,请使用 UIViewAnimationOptionBeginFromCurrentState
)。
关于ios - 暂停 UIView 的关键帧动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20403610/