是否可以使用动画删除SuperSuperview? [英] Is it possible to removeFromSuperview with Animation?

查看:78
本文介绍了是否可以使用动画删除SuperSuperview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have 2 layer is top and bottom on my program

我如何删除带有动画的顶层或带顶层到底是否可能?

how can i remove top layer with animation or bring top layer to back is it possible?

推荐答案

最简单的方法是在删除帧之前使用帧和alpha。

The easiest is playing with frame and alpha before removing it.

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

You can get some cool effects

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

iOS更新

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

You can now use blocks to perform your animation

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

这篇关于是否可以使用动画删除SuperSuperview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆