dismiss ios pop效果_iOS自定义转场动画-present和dismiss

自定义present、dismiss转场动画的步骤和自定义push、pop转场动画的步骤是一致的,相关内容请看《iOS自定义转场动画-push和pop》。

主要涉及的API

push和pop自定义转场动画通过导航控制器的UINavigationControllerDelegate配置,而present和dismiss自定义转场动画通过控制器的本身属性transitioningDelegate(UIViewControllerTransitioningDelegate)配置。

下面是要用到UIViewControllerTransitioningDelegate的几个方法:

//指定present动画

- (nullable id )animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source;

//指定dismiss动画

- (nullable id )animationControllerForDismissedController:(UIViewController *)dismissed;

//指定交互式present动画的控制类

- (nullable id )interactionControllerForPresentation:(id )animator;

//指定交互式dismiss动画的控制类

- (nullable id )interactionControllerForDismissal:(id )animator;

present转场动画

1、准备工作:

ViewController类,要present到的下一级控制器SecondViewController类。

2、实现present动画:

这里演示的动画类似原生的push和pop动画,present时界面由右向左覆盖上一级界面,dismiss相反过程。

HSLeftPresentAnimation类定义:

@interface HSLeftPresentAnimation : NSObject

@property (nonatomic, assign) BOOL isPresent;

@end

为了方便我们将present和dismiss动画写在一起&

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值