You could use a CATransition
to achieve this sort of effect quite easily. For example:
CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = 0.3f;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromRight;
[self.view.layer addAnimation:animation forKey:@"transition"];
// swap out your views here - either add / remove subviews or show / hide subviews
[self.view addSubview:otherView];
When animating the other way, change the subtype
to kCATransitionFromLeft
.
You'll also need to link to the QuartzCore
framework, and import <QuartzCore/QuartzCore.h>