CABasicAnimation 按home键后台之后,再切回来动画就停止了

解决方法:

1. CABasicAnimation *thisAnimation = [CABasicAnimtaion animationWithKeyPath:@"transform.rotation.z"];

    thisAnimation.removedOnCompletion = NO; 

/* When true, the animation is removed from the render tree once its
 * active duration has passed. Defaults to YES. */

@property(getter=isRemovedOnCompletion) BOOL removedOnCompletion;

2. 对UIApplicationWillEnterForegroundNotification增加observer, 然后在其中重启动画...

   旧动画直接removeAllAnimations, 然后重新创建和添加动画.

3. 

   1). 所在类注册监听 
       [notify addObserver:self    selector:@selector(doAnimation:)    name:UIApplicationDidBecomeActiveNotification object:nil];
   2). 实现自定义的方法doAnimation:,再次方法中添加动画
       - (void)doAnimation:(NSNotification *)notify{
           .....
           [obj addAnimate];
           ..... 
       } 

posted @ 2016-05-20 15:18  AntonyGu  阅读(2425)  评论(0编辑  收藏  举报