iOS7新特性 ViewController轉(zhuǎn)場(chǎng)切換(一) 以前總結(jié)和關(guān)鍵API介紹(轉(zhuǎn))

z ?@在iOS7之前,View Controller的切換主要有4種:

1.Push/Pop,NavigationViewController

2. Present and dismis Modal

3. UITabBarController

4. addChildViewController(一般用于自定義的繼承于 UIViewController 的容器子類)

iOS5,調(diào)用- (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion NS_AVAILABLE_IOS(5_0);

(1)前面3種方法這里就不多說(shuō)了,很常見(jiàn)的系統(tǒng)方法.至于第四種,我在前面文章-剖析網(wǎng)易標(biāo)簽欄的效果中已經(jīng)做了闡述,但是它提供的容器轉(zhuǎn)場(chǎng)動(dòng)畫只可以實(shí)現(xiàn)一些簡(jiǎn)單的UIView動(dòng)畫,但是難以重用,耦合高.

(2)關(guān)鍵的API:

A.動(dòng)畫控制器 (Animation Controllers) 遵從 UIViewControllerAnimatedTransitioning 協(xié)議,并且負(fù)責(zé)實(shí)際執(zhí)行動(dòng)畫。

B.交互控制器 (Interaction Controllers) 通過(guò)遵從 UIViewControllerInteractiveTransitioning 協(xié)議來(lái)控制可交互式的轉(zhuǎn)場(chǎng)。

C.轉(zhuǎn)場(chǎng)代理 (Transitioning Delegates) 根據(jù)不同的轉(zhuǎn)場(chǎng)類型方便的提供需要的動(dòng)畫控制器和交互控制器。

其中UINavigationControllerDelegate delegate 中新增了2個(gè)方法給NavigationController

UIViewControllerTransitioningDelegate 新增transitioningDelegate ?給Modal的Present和Dismis

UITabBarControllerDelegate ?delegate

- (id )tabBarController:(UITabBarController *)tabBarController

interactionControllerForAnimationController: (id )animationController NS_AVAILABLE_IOS(7_0);

- (id )tabBarController:(UITabBarController *)tabBarController

animationControllerForTransitionFromViewController:(UIViewController *)fromVC

toViewController:(UIViewController *)toVC ?NS_AVAILABLE_IOS(7_0);

D.轉(zhuǎn)場(chǎng)上下文 (Transitioning Contexts) 定義了轉(zhuǎn)場(chǎng)時(shí)需要的元數(shù)據(jù),比如在轉(zhuǎn)場(chǎng)過(guò)程中所參與的視圖控制器和視圖的相關(guān)屬性。 轉(zhuǎn)場(chǎng)上下文對(duì)象遵從 UIViewControllerContextTransitioning 協(xié)議,并且這是由系統(tǒng)負(fù)責(zé)生成和提供的。

E.轉(zhuǎn)場(chǎng)協(xié)調(diào)器(Transition Coordinators) 可以在運(yùn)行轉(zhuǎn)場(chǎng)動(dòng)畫時(shí),并行的運(yùn)行其他動(dòng)畫。 轉(zhuǎn)場(chǎng)協(xié)調(diào)器遵從 UIViewControllerTransitionCoordinator 協(xié)議。

(3)新的API主要提供了2種VC切換的方式:

A.非交互式切換,即定義一種從一個(gè)VC到另一個(gè)VC的動(dòng)畫效果,切換的時(shí)候自動(dòng)播放,

B.交互式切換,這種方式同樣需要定義動(dòng)畫效果,只是這個(gè)動(dòng)畫效果會(huì)根據(jù)跟隨交互式手勢(shì)來(lái)切換VC并同時(shí)播放動(dòng)畫效果。iOS7提供了一個(gè)默認(rèn)的基于百分比的動(dòng)畫實(shí)現(xiàn) UIPercentDrivenInteractiveTransition,而且根據(jù)WWDC的說(shuō)明,最簡(jiǎn)單的實(shí)現(xiàn)交互式動(dòng)畫的方法就是通過(guò)繼承 UIPercentDrivenInteractiveTransition。

原文:http://blog.csdn.net/hmt20130412/article/details/39079905

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容