tags:

views:

260

answers:

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?

+4  A: 

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];
}
F.Santoni
when i comment//[myView removeFromSuperView];it work.could you explane me why i must comment that line , Xcode tell me UIView may not response removeFromSuperView
RAGOpoR
I didn't really test this code, but without the removeFromSuperview the view is only hidden (alpha = 0).Just put the SuperView 'v' in lowercase : [myView removeFromSuperview];
F.Santoni
thanks santoni according to your suggestion to change V to lowercase it work but it not have an animation
RAGOpoR
tips :add after beginAnimations,[UIView setAnimationDuration:1]; // Time in secondI think animation is performed but too quickly
F.Santoni
A: 

Thank you santoni

my class are inherit from UIViewController

it not have frame

could you give me some another example please?

RAGOpoR
UIView *someView = yourViewController.view;
wkw
Thank you wkwit work!
RAGOpoR