You can use a Core Animation transition. You need to turn on layer backing for the parent view, and then you can do
[[parentView animator] replaceSubview:oldView with:newView];
By default that will crossfade the views, but if you want to change it to a slide animation then you'd add the appropriate CATransition to the animations dictionary.
- (CATransition *)slideAnimation
{
CATransition *transition = [CATransition animation];
[transition setType:kCATransitionMoveIn];
[transition setSubtype:kCATransitionFromRight];
return transition;
}
and then to set that animation in your parentView
...
[parentView setAnimations:[NSDictionary dictionaryWithObject:[self slideAnimation] forKey:@"subviews"];
...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…