Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show animation when addsubview

I want to add a subview with animation. I am using add sub view so it is not showing any animation so I want to show any animation when I am doing this... I am using below code :-

UIViewController *vControllerHome = [[viewTemp alloc] initWithNibName:@"viewTemp" bundle:nil];
vControllerHome.view.frame =CGRectMake(0, 0, 320, 414);
[self.view addSubview:vControllerHome.view];
self.selectedViewController = vControllerHome;

Can any one suggest how I do this?

like image 633
Mitesh Khatri Avatar asked Sep 06 '10 08:09

Mitesh Khatri


2 Answers

Here's the code.. Just try it.

PS: Replace myView with the name of the view you want to replace.

CATransition *applicationLoadViewIn =[CATransition animation];
[applicationLoadViewIn setDuration:duration];
[applicationLoadViewIn setType:kCATransitionReveal];
[applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[[myView layer]addAnimation:applicationLoadViewIn forKey:kCATransitionReveal];
like image 157
Suresh Varma Avatar answered Nov 01 '22 16:11

Suresh Varma


here is for animation blocks

[UIView transitionWithView:containerView 
                  duration:0.5 
               options:UIViewAnimationTransitionFlipFromRight //any animation
            animations:^ { [containerView addSubview:subview]; }
            completion:nil];
like image 27
adedoy Avatar answered Nov 01 '22 17:11

adedoy