You may know how to do transition from one view to another using buttons. However, the transitioning happens very quickly, and isn't exciting visually. To add transitions like inbuilt photo application on iPhone, you will need to add some animations to the transition. Luckily it is very easy to do using the APIs provided in the iPhone SDK.
To add the transition between views as a smooth page-turn animation following code will be helpful.
otherViewController = [[otherViewController alloc]
initWithNibName:@"OtherView"
bundle:nil];
[UIView beginAnimations:@"Animating view" context:nil];
// Animation duration to one second
[UIView setAnimationDuration:1];
/* Animation curve is set to UIViewAnimationCurveEaseInOut (other available animation types are UIViewAnimationCurveEaseIn, UIViewAnimationCurveEaseOut, and UIViewAnimationCurveLinear) */
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
/* Animation transition type is set to UIViewAnimationTransitionCurlDown (other available animation transitioning types are UIViewAnimationTransitionFlipFromLeft, UIViewAnimationTransitionFlipFromRight, and UIViewAnimationTransitionCurlUp)*/
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:self.view cache:YES];
[self.view addSubview:otherViewController.view];
[UIView commitAnimations];
No comments:
Post a Comment