標籤:
2、Modal Presentation Styles(彈出風格)
通過設定presenting VC的modalPresentationStyle屬性,我們可以設定彈出View Controller時的風格,有以下四種風格,其定義如下:
複製代碼代碼如下:
typedef enum {
UIModalPresentationFullScreen = 0,
UIModalPresentationPageSheet,
UIModalPresentationFormSheet,
UIModalPresentationCurrentContext,
} UIModalPresentationStyle;
UIModalPresentationFullScreen代表彈出VC時,presented VC充滿全屏,如果彈出VC的wantsFullScreenLayout設定為YES的,則會填充到狀態列下邊,否則不會填充到狀態列之下。
UIModalPresentationPageSheet代表彈出是彈出VC時,presented VC的高度和當前螢幕高度相同,寬度和豎屏模式下螢幕寬度相同,剩餘未覆蓋地區將會變暗並阻止使用者點擊,這種彈出模式下,豎屏時跟UIModalPresentationFullScreen的效果一樣,橫屏時候兩邊則會留下變暗的地區。
UIModalPresentationFormSheet這種模式下,presented VC的高度和寬度均會小於螢幕尺寸,presented VC置中顯示,四周留下變暗地區。
UIModalPresentationCurrentContext這種模式下,presented VC的彈出方式和presenting VC的父VC的方式相同。
這四種方式在iPad上面統統有效,但在iPhone和iPod touch上面系統始終已UIModalPresentationFullScreen模式顯示presented VC。
3、Modal Transition Style(彈出時的動畫風格)
通過設定設定presented VC的modalTransitionStyle屬性,我們可以設定彈出presented VC時情境切換動畫的風格,其定義如下:
複製代碼代碼如下:
typedef enum {
UIModalTransitionStyleCoverVertical = 0,
UIModalTransitionStyleFlipHorizontal,
UIModalTransitionStyleCrossDissolve,
UIModalTransitionStylePartialCurl,
} UIModalTransitionStyle;
我們可以看到有從底部滑入,水平翻轉進入,交叉溶解以及翻頁這四種風格可選。這四種風格在不受裝置的限制,即不管是iPhone還是iPad都會根據我們指定的風格顯示轉場效果。
模態推出方式