是否可以使用动画删除SuperSuperview?

RAG*_*poR 2 iphone

我的程序上有2层是顶部和底部

如何删除顶层动画或顶层返回是否可能?

Fra*_*scu 11

最简单的方法是在删除之前使用框架和alpha.

你可以得到一些很酷的效果

-(void)removeWithEffect:(UIView *)myView
{
 [UIView beginAnimations:@"removeWithEffect" context:nil];
 [UIView setAnimationDuration:0.5f];
 //Change frame parameters, you have to adjust
 myView.frame = CGRectMake(0,0,320,480);
 myView.alpha = 0.0f;
 [UIView commitAnimations];
 [myView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.5f];
}
Run Code Online (Sandbox Code Playgroud)

iOS更新

您现在可以使用块来执行动画

[UIView animateWithDuration:0.5f
     animations:^{view.alpha = 0.0;}
     completion:^(BOOL finished){ [view removeFromSuperview]; }];
Run Code Online (Sandbox Code Playgroud)


Jos*_*phH 7

如果您向上定向iOS 4.0,则可以使用动画块:

[UIView animateWithDuration:0.2
     animations:^{view.alpha = 0.0;}
     completion:^(BOOL finished){ [view removeFromSuperview]; }];
Run Code Online (Sandbox Code Playgroud)

(上面的代码来自Apple的UIView文档)