模态视图的概念以及显示、变换方式介绍

学几个单词

 

dissolve [dɪ'zɒlv] vi.溶解;解散

curl [kɜːl] vi. 卷曲

 

什么是模态视图?

 

比如UIAlertView,它就是一个模态视图。对于模态视图和普通视图最主要的区别就是模态视图显示的时候不能对其他视图进行操作。主要用来收集或显示一些信息。

 

思考:弹出警告框的时候,背景视图变暗不能操作,所以说警告框就是一个模态视图。

 

PresentationStyle(显示方式)

 

对于iPhone来讲PresentationStyle始终是UIModalPresentationFullScreen模式显示ModelViewController

 

对于iPad有四种显示方式,如下所示(默认全屏)

 

typedefenum {
    UIModalPresentationFullScreen = 0,
   UIModalPresentationPageSheet,
   UIModalPresentationFormSheet,
   UIModalPresentationCurrentContext,
} UIModalPresentationStyle;

 

UIModelPresentationFullScreen弹出VC时,被弹出的视图(presentedVC)充满全屏

UIModalPresentationPageSheet弹出VC时,presentedVC的height、width和presenting VC相同,竖屏时和UIModelPresentationFullScreen相同,横屏时未覆盖区域变暗并阻止用户点击

UIModelPresentationFromSheet弹出VC时,presentedVC的height、width均会小于presentingVC,且presented居中显示,四周变暗

UIModalPresentationCurrentContext弹出VC时,和presentedVC的弹出方式相同

 

 

TransitionStyle(变换效果)

 

默认的presented方式是CoverVertical(竖直覆盖),也可以设置水平翻转、交叉溶解、翻页等效果

 

typedefenum {
       UIModalTransitionStyleCoverVertical = 0,
       UIModalTransitionStyleFlipHorizontal,
       UIModalTransitionStyleCrossDissolve,
        UIModalTransitionStylePartialCurl,
} UIModalTransitionStyle;

 

DelegateDismiss ModalViewController

 

dismissViewControllerAnimated:completion,对于这个方法的调用者最简单的是[selfdismissViewControllerAnimated:completion],如果presentedVC和presenting VC之间有数据传递的话,建议在presentedVC中使用代理方法dissmiss掉presented VC

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章