のサブビューの1つをアニメートし、UIWindow
それをUIWindow
使用から削除するメソッドがありremoveFromSuperview
ます。しかし、removeFromSuperview
アニメーションブロックの後に置くと、アニメーションが再生される前にからが削除されるため、アニメーションが表示さremoveFromSuperview
れません:-(アニメーションが最初に再生されてからサブビューが削除されるように遅延するにはどうすればよいですか?アニメーションブロックの後に試しましたが、表示されませんでしたアニメーションも何らかの理由でスリープするため、望ましい効果があります。UIView
UIWindow
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];
}