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];
           ..... 
       } 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM