美文网首页
iOS让push跳转动画像modal跳转动画那样效果

iOS让push跳转动画像modal跳转动画那样效果

作者: 忆一曲肝肠断 | 来源:发表于2020-05-02 21:18 被阅读0次

    iOS让push跳转动画像modal跳转动画那样效果(从下往上推上来),iOS核心动画有很多,转场啊,属性动画,基础动画,关键帧动画,弹簧动画,动画组,CoreAnimation类结构,今天讲的是CATransition实现的,废话不多说,上代码。
    push

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

    pop

    - (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让push跳转动画像modal跳转动画那样效果

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