How to pushViewController with grow up animation
Just add this code to your file.
@implementation UINavigationController (Dummy)
-(void)enlarge:(UIViewController *)controller fromView:(UIView *)view animated:(BOOL)animated
{
UIImageView *imageV=[self takeSnapshot:controller];
CGRect sourceFrame=view.frame;
CGRect destFrame=controller.view.frame;
[imageV setFrame:sourceFrame];
[self.view addSubview:imageV];
[UIView animateWithDuration:0.3 animations:^{
[imageV setFrame:destFrame];
} completion:^(BOOL finished) {
[self pushViewController:controller animated:NO];
[imageV removeFromSuperview];
}];
}
-(UIImageView *)takeSnapshot:(UIViewController *)controller
{
UIGraphicsBeginImageContext(self.view.frame.size);
CGContextRef context=UIGraphicsGetCurrentContext();
[controller.view.layer renderInContext:context];
UIImage *image=UIGraphicsGetImageFromCurrentImageContext();
UIImageView *imageView=[[UIImageView alloc] initWithImage:image];
UIGraphicsEndImageContext();
return imageView;
}
@end
Comments
Post a Comment