View Transition Animation
I have this code:
- (void) displayView:(int)intNewView{
NSLog(@"%i", intNewView);
[currentView.view removeFromSuperview];
[currentView release];
switch (intNewView) {
case 1:
currentView = [[EnterView alloc] init];
break;
case 2:
currentView = [[MainMenuView alloc] init];
break;
case 3:
currentView = [[DetailsView alloc] init];
break;
case 4:
currentView = [[PhotosView alloc] init];
break;
case 5:
开发者_如何学编程 currentView = [[CustomUITableViewViewController alloc] init];
break;
}
[self.view addSubview:currentView.view];
}
This code successfully transitions views, however its not very spectacular as you can imagine (the view simply switches with no animation). I'm wondering if there is a simple way to add any kind of simple view transition animation here? I can't figure out how to implement any of the example I've found online. Any animation would suffice, just something to spice things up a bit :)
Thanks,
Jack
You can simply use basic core animations:
Like this:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[self.view addSubview:currentView.view];
[UIView commitAnimations];
You can try different UIViewAnimationTransitions, for the "forView" you enter the view that currently is on the screen. Hope that helped.
精彩评论