美文网首页
iOS navigationController push动画

iOS navigationController push动画

作者: Cary9396 | 来源:发表于2019-07-23 14:24 被阅读0次

    提供一个简单的实现方式,代码如下:

    - (void)push {
    
            TestViewController *vc = [[TestViewController alloc] init];
            vc.view.backgroundColor = [UIColor redColor];
            CATransition* transition = [CATransition animation];
            transition.duration =0.4f;
            transition.type = kCATransitionMoveIn;
            transition.subtype = kCATransitionFromTop;
            [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
            [self.navigationController pushViewController:vc animated:NO];
        }
    
        - (void)pop {
    
            CATransition* transition = [CATransition animation];
            transition.duration =0.4f;
            transition.type = kCATransitionReveal;
            transition.subtype = kCATransitionFromBottom;
            [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
            [self.navigationController popViewControllerAnimated:NO];
        }
    

    相关文章

      网友评论

          本文标题:iOS navigationController push动画

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