IOS 自定义界面切换动画-Custom Segue

原创Blog,转载请注明出处

http://blog.csdn.net/hello_hwc?viewmode=contents

实现方式就是继承UIStoryboardSegue类,然后重写Perform方法,然后在Storyboard上将类设置为自定义的类


这段代码的作用是创建从中心渐变充满屏幕的动画

-(void)perform{
    UIViewController * svc = self.sourceViewController;
    UIViewController * dvc = self.destinationViewController;
    [svc.view addSubview:dvc.view];
    [dvc.view setFrame:svc.view.frame];
    [dvc.view setTransform:CGAffineTransformMakeScale(0.1, 0.1)];
    [dvc.view setAlpha:0.0];
    [UIView animateWithDuration:1.0
                     animations:^{
                         [dvc.view setTransform:CGAffineTransformMakeScale(1.0, 1.0)];
                         [dvc.view setAlpha:1.0];
                     }
                     completion:^(BOOL finished) {
//                         [dvc.view removeFromSuperview];
                     }];
}
最后的示意

IOS 自定义界面切换动画-Custom Segue_第1张图片                    

完整的Demo工程

http://pan.baidu.com/s/1qWodA7E

你可能感兴趣的:(ios,自定义动画,customSegue)