views:

260

answers:

3

Hi, I have a UIView that I use as a container for four separate subviews. At any one time, only one of the subviews is visible and the rest are hidden. Right now, when switching between the views, all I am working with is setting or inserting the hidden property.

I'd like to have some sort of an animated transition to give the app a bit more polish, but can't quite make sense of some of the other posts I've read.

Could someone walk me through how to animate transitions from one subviews to another within a containing UIView?

Thanks!

A: 

I know that you can remove views and animate that way (with view controllers). I'm not sure though if there is a way of using the hidden property and still animating with that? I'm fairly new to the Obj-C game as well.

Lucas Derraugh
+1  A: 

Try to read about transitionFromView:toView:duration:options:completion: here

Idan
A: 

Try playing around with this code. This must be very close to what you need.

      CATransition *transition = [CATransition animation];
      transition.duration = 0.5; 
      transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
      transition.type = kCATransitionPush;
      transition.subtype = kCATransitionFromLeft;
      transition.delegate = self;
      [self.navigationController.view.layer addAnimation:transition forKey:nil];

      self.navigationController.navigationBarHidden = NO; 
      [self.navigationController popViewControllerAnimated:YES]

;

eviltrue