開發過程中常用的關于函數有以下幾個:
1.[UIView animateWithDuration: animations:^{} completion:^(BOOL finished) {}];
2.[UIView animateWithDuration: animations:^{}];
3.[UIView animateWithDuration: delay: options: animations: completion:^(BOOL finished) {}];
前兩個動畫的函數的使用,沒有太多的可講.第三個動畫,多了一個options選項.需要我們傳入一個枚舉,這個枚舉主要的作用:當前的動畫執行隨時間函數變化(由快變慢,由慢變快等...效果).可以實現類似淡入淡出的效果.
介紹:
UIViewAniOpinionLayoutSubviews //子視圖中控講將跟父視圖中控件使用相同的動畫
UIViewAnimationOptionAllowUserInteraction //動畫時允許用戶交互
UIViewAnimationOpinionBeginFromCurrentState //重當前狀態開始執行動畫
UIViewAnimationOptionRepeat //動畫一直重復播放
UIViewAnimationOptionAutoreverse //執行動畫回路,前提是設置動畫無限重復
UIViewAnimationOptionOverrideInheritedDuration //忽略外層動畫嵌套的執行時間
UIViewAnimationOptionOverrideInheritedCurve //忽略外層動畫嵌套的時間變化曲線
UIViewAnimationOptionAllowAnimatedContent //通過改變屬性和重繪實現動畫效果,如果key沒有提交動畫將使用快照
UIViewAnimationOptionOverrideInheritedOptions //忽略嵌套繼承的?選項
//時間函數曲線相關
UIViewAnimationOptionCurveEaseInOut //時間曲線函數,由慢到快
UIViewAnimationOptionCurveEaseIn //時間曲線函數,由慢到特別快
UIViewAnimationOptionCurveEaseOut //時間曲線函數,由快到慢
UIViewAnimationOptionCurveLinear //時間曲線函數,勻速
轉場動畫它一般是用在這個方法中的:
[UIView transitionFromView: toView: duration: options: completion:^(BOOL finished) {}];
//相關的轉場動畫
UIViewAnimationOptionTransitionNone //無轉場動畫
UIViewAnimationOptionTransitionFlipFromLeft //轉場從左翻轉
UIViewAnimationOptionTransitionFlipFromRight //轉場從右翻轉
UIViewAnimationOptionTransitionCurlUp //上卷轉場
UIViewAnimationOptionTransitionCurlDown //下卷轉場
UIViewAnimationOptionTransitionCrossDissolve //轉場交叉消失
UIViewAnimationOptionTransitionFlipFromTop //轉場從上翻轉
UIViewAnimationOptionTransitionFlipFromBottom //轉場從下翻轉