码迷,mamicode.com
首页 > 其他好文 > 详细

简单通过Storyboard的Segue做视图切换动画

时间:2015-04-02 06:56:28      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

首先在storyboard里面定义连线,连的线,然后设置为custom的类型 

然后新增一个UIStoryboardSegue的子类重写它的-(void)perform 方法

再把segue的属性segue class设置为你自己新建的那个segue的子类

-(void)perform{
  
    UIViewController *dest = self.destinationViewController;
    UIViewController *src = self.sourceViewController;
    CGRect f = src.view.frame;
    CGRect originalSourceRect = src.view.frame;
    f.origin.y = f.size.height;
    [UIView animateWithDuration:0.3 animations:^{
        src.view.frame = f;
    } completion:^(BOOL finished) {
        src.view.alpha = 0 ;
        dest.view.frame = f;
        dest.view.alpha=0.0f;
        [src.view.superview addSubview:dest.view];
        [UIView animateWithDuration:0.3 animations:^{
            dest.view.frame = originalSourceRect;
            dest.view.alpha = 1.0f;
            
        } completion:^(BOOL finished) {
            [dest.view removeFromSuperview];
            src.view.alpha = 1.0f;
            [src.navigationController pushViewController:dest animated:NO];
        }];
    }];
    
}





简单通过Storyboard的Segue做视图切换动画

标签:

原文地址:http://my.oschina.net/u/865478/blog/394816

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!