标签: commitanimations

UIView removeFromSuperView动画延迟

我有一个方法,动画其中一个子视图,UIWindow然后将其从UIWindow使用中删除removeFromSuperview.但是,当我把removeFromSuperview动画块后,动画从来没有显示,因为removeFromSuperview消除了UIViewUIWindow动画播放:-(之前,我怎样才能延缓removeFromSuperview所以播放动画,然后再子视图被删除?我试图[NSThread sleepForTimeInterval:1];动画块后,但没有有理想的效果,因为动画因某种原因也会睡觉.

我的这个方法的代码:

  - (void) animateAndRemove
    {
     NSObject *mainWindow = [[UIApplication sharedApplication] keyWindow];

     [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.8]; 
     UIView *theView = nil;
     for (UIView *currentView in [mainWindow subviews])
     {
      if (currentView.tag == 666)
      {
       currentView.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.0];
       theView = currentView;
       }
     }
     [UIView setAnimationTransition:  UIViewAnimationTransitionNone forView:theView cache:YES];
      [UIView commitAnimations]; 



 //[NSThread sleepForTimeInterval:1];

 [theView removeFromSuperview];


    }
Run Code Online (Sandbox Code Playgroud)

iphone animation uiview commitanimations

4
推荐指数
2
解决办法
5827
查看次数

标签 统计

animation ×1

commitanimations ×1

iphone ×1

uiview ×1