【发布时间】:2017-04-17 12:15:19
【问题描述】:
我正在编写一个页面来检查设备是否已链接到系统。 页面每 2 秒发送一次请求,共 6 次,在此期间(可能长达 10 秒)页面显示动画加载循环。
问题是:当我按下主页按钮并立即重新打开应用程序时,动画停止。
这是我所知道的:
动画的两种实现方式:
-
CABasicAnimation:CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = @(2 * M_PI); rotationAnimation.duration = 1.5; rotationAnimation.cumulative = YES; [loadingCircle.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; -
UIView animateWithDuration...:- (void)rotateView:(UIView *)view { [UIView animateWithDuration:0.75 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ view.transform = CGAffineTransformRotate(view.transform, M_PI); } completion:^(BOOL finished) { if (finished) { [self rotateView:view]; } }]; } ... - viewDidLoad { ... [self rotateView:loadingCircle]; }
我知道在第一个实现中,设置rotationAnimation.removedOnCompletion = NO; 将恢复动画。
我的问题是:当我使用第二种实现时,实现相同效果的等效方法是什么。
【问题讨论】:
-
在appdelegate类中调用applicationDidBecomeActive中的动画方法
-
我通过在本地班级订阅通知来做到这一点。谢谢。
标签: ios objective-c animation