Friday, November 2, 2012

Curl view animation using UInavigation controller

This small post is about creating custom curl animation same like mapview using UINavigation controller rather than UImodalViewController.


Function to go on next view :


- (IBAction)fnButtonForMapViewPressed:(UIButton *)sender {
    

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration: 0.50];
    
    
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:YES];
    
    //Create ViewController
    vc *vc_obj=[[vc alloc]initWithNibName:@"vc" bundle:nil];
    
    [self.navigationController pushViewController:vc_obj animated:NO];
    
    //Start Animation
    [UIView commitAnimations];


}


Function to go back on previous view :

- (IBAction)fnButtonForBackButtonPressed:(id)sender
{
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration: 0.50];
    
    
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:YES];
    
    [self.navigationController popToRootViewControllerAnimated:NO];

    //Start Animation
    [UIView commitAnimations];

}


To provide better illusion add curl image to button.

Njoy..Happy Coding