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

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

作者: 此笙吥涣 | 来源:发表于2018-03-28 15:10 被阅读0次

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

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

    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];

    }

    相关文章

      网友评论

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

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