ios8中 利用UIPresentationController 自定义转场
来源:互联网 发布:mac粉底液色号分类 编辑:程序博客网 时间:2024/06/04 18:54
1、UIPresentationController 介绍
UIPresentationController 是 iOS8 新增的一个 API,用来控制 controller 之间的跳转特效。比如希望实现一个特效,显示一个窗口,大小和位置都是自定义的,并且遮罩在原来的页面上。在之前,可以操作view的一些方法来实现。
2、使用介绍
1. 设置目标控制器的 转场代理 和 展示方法
controller.modalPresentationStyle = UIModalPresentationStyle.Custom// 设置 动画样式controller.transitioningDelegate = transtinoDelegate// 此对象要实现 UIViewControllerTransitioningDelegate 协议
2. transtionDelegate 实现 UIViewControllerTransitioningDelegate 协议方法// 返回控制控制器弹出动画的对象optional func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning?// 返回控制控制器消失动画的对象optional func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?@availability(iOS, introduced=8.0)// 返回控制控制器跳转的对象optional func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController!, sourceViewController source: UIViewController) -> UIPresentationController?
3. 控制控制器跳转的类控制控制器跳转的类继承自 UIPresentationController
/*构造方法:参数:presentedViewController将要跳转到的目标控制器presentingViewController跳转前的原控制器*/init(presentedViewController: UIViewController!, presentingViewController: UIViewController!)
常用的属性和方法presentedViewController:要 modal 显示的视图控制器presentingViewController:低层的视图控制器containerView()容器视图presentedView()被展现的视图func presentationTransitionWillBegin()跳转将要开始func presentationTransitionDidEnd(completed: Bool)跳转完成func dismissalTransitionWillBegin()dismiss 将要开始func dismissalTransitionDidEnd(completed: Bool)dismiss 完成func frameOfPresentedViewInContainerView()目标 控制器设置
4. 控制动画类
控制动画对类继承自 UIViewControllerAnimatedTransitioning
// 执行动画的时间func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval// 动画过程设置func animateTransition(transitionContext: UIViewControllerContextTransitioning)5. 总结
1. 设置目标控制器的转场代理
2. 专场代理返回三个对象用于控制转场过程
3. 控制控制器转场对象,可以在此做专场前后的操作,例如添加遮罩等
4. 控制转场动画,用于设置目标控制器出现或消失的动画,以及控制器的大小样式等。
3. API 详细介绍
1、UIViewControllerTransitioningDelegate
protocol UIViewControllerTransitioningDelegate : NSObjectProtocol {// 返回控制控制器消失动画的对象optional func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning?// 返回控制控制器跳转的对象optional func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?optional func interactionControllerForPresentation(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?optional func interactionControllerForDismissal(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?@availability(iOS, introduced=8.0)// 返回控制控制器弹出动画的对象optional func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController!, sourceViewController source: UIViewController) -> UIPresentationController?}
2、UIPresentationController
4.自定义跳转 Demo
稍后。。。
1 1
- ios8中 利用UIPresentationController 自定义转场
- UIPresentationController自定义转场动画
- 自定义UIPresentationController
- iOS8的UIPresentationController
- iOS8新特性 UIPresentationController(一)
- UIPresentationController
- UIPresentationController
- UIPresentationController
- 自定义转场
- iOS7中ViewControllers之间自定义转场动画
- [iOS8][Segue转场]转场返回无法绑定的解决办法
- 怎样自定义设置EDIUS中2D转场特效
- 自定义 ViewController 容器转场
- iOS自定义转场动画
- 自定义UIViewController转场、GPUImage
- iOS自定义转场动画
- 自定义转场动画
- IOS 自定义转场动画。
- Python抓取简书的热门文章
- 数据库 索引原理
- java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.TextView解决办法
- 你真的会用OnTouchListener、OnClickListener、OnLongClickListener监听事件么?
- 2015/5/25:写在入职华为前夜
- ios8中 利用UIPresentationController 自定义转场
- 省赛第一个氺题--结构体二级排序
- 最近用android写的一个项目,开发心得
- Spring3表达式语言(SpEL)学习笔记
- 百度之星程序设计竞赛资格赛:1004放盘子
- 由浅入深探究mysql索引结构原理、性能分析与优化
- MySQL之旅_Day04
- 怎样尊重一个程序员
- C#中的多线程