首先這個(gè)枚舉屬于UIViewAnimation。我們經(jīng)常使用的函數(shù)是[UIView animateWithDuration: animations:^{} completion:^(BOOL finished) {}];和[UIView animateWithDuration: animations:^{}];如果動(dòng)畫稍微復(fù)雜點(diǎn),例如需要組合等等就可能用到這個(gè)函數(shù):[UIView animateWithDuration: delay: options: animations: completion:^(BOOL finished) {}];剛開始接觸的朋友看到一堆枚舉可能就覺得煩,尤其是蘋果那混亂的動(dòng)畫框架東一坨,西一坨。又是Quartz2D,又是核心動(dòng)畫跟臭襪子一樣……沒關(guān)系,撿回來接著穿。
以上方法中的options一項(xiàng)需要傳入一個(gè)枚舉,這個(gè)枚舉大概控制的是這幾個(gè)要素:當(dāng)前動(dòng)畫嵌套中的動(dòng)畫執(zhí)行隨時(shí)間的快慢種類(先快后慢等..)。動(dòng)畫要一直重復(fù)嗎。如果我使用轉(zhuǎn)場(chǎng)動(dòng)畫那么我用哪種轉(zhuǎn)場(chǎng)效果。還有子動(dòng)畫嵌套在父動(dòng)畫中時(shí)我們?nèi)绾螌?duì)待父動(dòng)畫中的相同選項(xiàng)等等..
正文:
UIViewAnimationOptionLayoutSubviews //提交動(dòng)畫的時(shí)候布局子控件,表示子控件將和父控件一同動(dòng)畫。
UIViewAnimationOptionAllowUserInteraction //動(dòng)畫時(shí)允許用戶交流,比如觸摸
UIViewAnimationOptionBeginFromCurrentState //從當(dāng)前狀態(tài)開始動(dòng)畫
UIViewAnimationOptionRepeat //動(dòng)畫無限重復(fù)
UIViewAnimationOptionAutoreverse //執(zhí)行動(dòng)畫回路,前提是設(shè)置動(dòng)畫無限重復(fù)
UIViewAnimationOptionOverrideInheritedDuration //忽略外層動(dòng)畫嵌套的執(zhí)行時(shí)間
UIViewAnimationOptionOverrideInheritedCurve //忽略外層動(dòng)畫嵌套的時(shí)間變化曲線
UIViewAnimationOptionAllowAnimatedContent //通過改變屬性和重繪實(shí)現(xiàn)動(dòng)畫效果,如果key沒有提交動(dòng)畫將使用快照
UIViewAnimationOptionShowHideTransitionViews //用顯隱的方式替代添加移除圖層的動(dòng)畫效果
UIViewAnimationOptionOverrideInheritedOptions //忽略嵌套繼承的?選項(xiàng)
//時(shí)間函數(shù)曲線相關(guān)
UIViewAnimationOptionCurveEaseInOut //時(shí)間曲線函數(shù),由慢到快
UIViewAnimationOptionCurveEaseIn //時(shí)間曲線函數(shù),由慢到特別快
UIViewAnimationOptionCurveEaseOut //時(shí)間曲線函數(shù),由快到慢
UIViewAnimationOptionCurveLinear //時(shí)間曲線函數(shù),勻速
//轉(zhuǎn)場(chǎng)動(dòng)畫相關(guān)的
UIViewAnimationOptionTransitionNone //無轉(zhuǎn)場(chǎng)動(dòng)畫
UIViewAnimationOptionTransitionFlipFromLeft //轉(zhuǎn)場(chǎng)從左翻轉(zhuǎn)
UIViewAnimationOptionTransitionFlipFromRight //轉(zhuǎn)場(chǎng)從右翻轉(zhuǎn)
UIViewAnimationOptionTransitionCurlUp //上卷轉(zhuǎn)場(chǎng)
UIViewAnimationOptionTransitionCurlDown //下卷轉(zhuǎn)場(chǎng)
UIViewAnimationOptionTransitionCrossDissolve //轉(zhuǎn)場(chǎng)交叉消失
UIViewAnimationOptionTransitionFlipFromTop //轉(zhuǎn)場(chǎng)從上翻轉(zhuǎn)
UIViewAnimationOptionTransitionFlipFromBottom //轉(zhuǎn)場(chǎng)從下翻轉(zhuǎn)
以上是淺略的理解,歡迎朋友有更好的指正,以免誤人子弟。
補(bǔ)充:關(guān)于最后一組轉(zhuǎn)場(chǎng)動(dòng)畫它一般是用在這個(gè)方法中的:
[UIView transitionFromView: toView: duration: options: completion:^(BOOL finished) {}];
該方法效果是插入一面視圖移除一面視圖,期間可以使用一些轉(zhuǎn)場(chǎng)動(dòng)畫效果。