美文网首页iOS
iOS开发:用CATransition改变PUSH的弹出方向

iOS开发:用CATransition改变PUSH的弹出方向

作者: iOS_SXH | 来源:发表于2017-01-19 10:59 被阅读620次

    问题:项目中页面跳转需要用模态效果(页面上下进入推出),但是进来的页面还还是需要导航。

    使用的是导航跳转(左右出现)页面,效果是模态效果(上下)出现页面


    PUSH 推入:模拟出模态弹出效果

    - (void)PushPresent {

    TWOViewController *vc = [TWOViewController new];

    CATransition *transition = [CATransition animation];

    transition.duration = 0.25;

    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];

    transition.type = kCATransitionPush;

    transition.subtype = kCATransitionFromTop;

    transition.delegate = self;

    [self.navigationController.view.layer addAnimation:transition forKey:nil];

    //隐藏跳转的页面的导航条:实质是PUSH,所以用POP 推出

    [self.navigationController pushViewController:vc animated:NO];

    }

    pop 弹出:模拟出模态弹出效果

    - (void)popDissmiss{

    CATransition *transition = [CATransition animation];

    transition.duration = 0.25;

    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];

    transition.type = kCATransitionPush;

    transition.subtype  = kCATransitionFromBottom;

    transition.delegate = self;

    [self.navigationController.view.layer addAnimation:transition forKey:nil];

    self.navigationController.navigationBarHidden = NO;

    [self.navigationController popViewControllerAnimated:NO];

    }

    学无止境,做个记录

    2017-01-19-SXH

    相关文章

      网友评论

        本文标题:iOS开发:用CATransition改变PUSH的弹出方向

        本文链接:https://www.haomeiwen.com/subject/hekmbttx.html