View transition animations

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 translates views, but its not very impressive, as you can imagine (the view simply switches without animation). I am wondering if there is an easy way to add any simplicity of the transition animation to a point? I cannot figure out how to implement any of the examples that I found on the Internet. Any animation would be sufficient, just a little tweak :)

Thanks,

Jack

+4
source share
1 answer

You can simply use basic basic 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 "forView" you enter the view that is currently on the screen. Hope this helps.

+7
source

All Articles