IOS ViewController切换动画以及如何返回

1.  ViewController提供了一个 presentViewController: *target animated: YES completion:^(void) 方法可以跳转到指定的target中,跳转的时候可以指定动画。

    [target setModalTransitionStyle:UIModaltransitionStyle]可以指定跳转时的动画,IOS系统提供了四中跳转动画,默认的是垂直切换动画。

Transition styles available when presenting view controllers.

typedef enum {

   UIModalTransitionStyleCoverVertical = 0,

   UIModalTransitionStyleFlipHorizontal,

   UIModalTransitionStyleCrossDissolve,

   UIModalTransitionStylePartialCurl,

} UIModalTransitionStyle;

2.   通过方法1中提供的方法切换ViewController,需要自己添加返回按钮,为按钮添加消息响应

      [self dismissViewController animated:YES  completion:nil];即可对应的动画返回启动此ViewController的启动界面。

      IOS官方文档对此的解释是:

The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, it automatically forwards the message to the presenting view controller.

If you present several view controllers in succession, thus building a stack of presented view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.

If you want to retain a reference to the receiver’s presented view controller, get the value in the presentedViewController property before calling this method.

The completion handler is called after the viewDidDisappear: method is called on the presented view controller

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW103


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值