present(模态)实现出push的效果

白侯林
2023-12-01

在present加上这个转场动画,取消掉原来的转场动画

  CATransition *animation = [CATransitionanimation];

    animation.duration = 0.35;

    animation.timingFunction = UIViewAnimationCurveEaseInOut;

    animation.type = kCATransitionPush;

  animation.subtype = kCATransitionFromRight;

    [self.view.window.layeraddAnimation:animation forKey:nil];

    [self presentViewController:setVC animated:NOcompletion:nil];

在dissmiss加上这个转场动画,取消掉原来的动画效果

      CATransition *animation = [CATransition animation];

 animation.duration = 0.35;

 animation.timingFunction = UIViewAnimationCurveEaseInOut;

 animation.type = kCATransitionPush;

 animation.subtype = kCATransitionFromLeft;

   [self.view.window.layer addAnimation:animation forKey:nil];

       [selfdismissViewControllerAnimated:NOcompletion:nil];

然后就和NavCtl的push效果和back效果几乎一致。

转载于:https://www.cnblogs.com/shizhiliblog/p/7679963.html

 类似资料: