push跳转实现模态跳转的效果

在登录注册时候基本百分百会遇到模态出来登录界面,然后push注册或者找回密码页面,模态再push是很恶心的事情,来回切换,还需要再创建一个导航控制器,那么,有什么方法可以简单一点呢,有,那就是利用动画以假乱真,下面直接上代码。

push跳转实现模态跳转的效果_第1张图片
00379DA1-2010-418E-8FF6-6C8DC1AE0952.png
push跳转实现模态跳转的效果_第2张图片
66CF60D9-1EBC-4249-A6BE-ABCB5907D9D2.png

只需要点击时候调用即可,可以自己封装一下。

    //模态push
    RegisterViewController *regist = [[RegisterViewController alloc] init];
    CATransition *transition = [CATransition animation];
    transition.duration = 0.3f;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionMoveIn;
    transition.subtype = kCATransitionFromTop;
    transition.delegate = self;
    [self.navigationController.view.layer addAnimation:transition forKey:nil];
    [self.navigationController pushViewController:regist animated:NO];
    //**pop回
            CATransition *transition = [CATransition animation];
            transition.duration = 0.3f;
            transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
            transition.type = kCATransitionReveal;
            transition.subtype = kCATransitionFromBottom;
            transition.delegate = weekSelf;
            [weekSelf.navigationController.view.layer addAnimation:transition forKey:nil];
            [weekSelf.navigationController popViewControllerAnimated:NO];

你可能感兴趣的:(push跳转实现模态跳转的效果)