[UIView animateWithDuration:1 delay:(0.1 + i * 0.1) usingSpringWithDamping:0.8 initialSpringVelocity:0.2 options:UIViewAnimationOptionCurveLinear animations:^{ editView.y = _topLabel.bottom + 30 * (i / 4 + 1) + 70 * (i / 4); } completion:nil];
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion API_AVAILABLE(ios(7.0))
usingSpringWithDamping
和 initialSpringVelocity
usingSpringWithDamping 參數
usingSpringWithDamping的範圍爲0.0f到1.0f,數值越小「彈簧」的振動效果越明顯。下圖演示了在initialSpringVelocity爲0.0f的狀況下,usingSpringWithDamping分別取0.2f,0.5f和1.0f的狀況,以下圖ios
usingSpringWithDamping
爲1.0f時,initialSpringVelocity
分別取5.0f,15.0f和25.0f的狀況。值得注意的是,初始速度取值較高而時間較短時,也會出現反彈狀況||
|:|
| UIViewAnimationOptionLayoutSubviews | 提交動畫的時候佈局子控件,表示子控件將和父控件一同動畫 |
| UIViewAnimationOptionAllowUserInteraction | 動畫時容許用戶交流,好比觸摸 |
| UIViewAnimationOptionBeginFromCurrentState | 從當前狀態開始動畫 |
| UIViewAnimationOptionRepeat | 動畫無限重複 |
| UIViewAnimationOptionAutoreverse | 執行動畫迴路,前提是設置動畫無限重複 |
| UIViewAnimationOptionOverrideInheritedDuration | 忽略外層動畫嵌套的執行時間 |
| UIViewAnimationOptionOverrideInheritedCurve | 忽略外層動畫嵌套的時間變化曲線 |
| UIViewAnimationOptionAllowAnimatedContent | 經過改變屬性和重繪實現動畫效果,若是key沒有提交動畫將使用快照|
| UIViewAnimationOptionShowHideTransitionViews | 用顯隱的方式替代添加移除圖層的動畫效果|
| UIViewAnimationOptionOverrideInheritedOptions | 忽略嵌套繼承的選項|ide
| 時間函數曲線相關||
|:|
| UIViewAnimationOptionCurveEaseInOut | 時間曲線函數,由慢到快|
| UIViewAnimationOptionCurveEaseIn | 時間曲線函數,由慢到特別快 |
| UIViewAnimationOptionCurveEaseOut | 時間曲線函數,由快到慢 |
| UIViewAnimationOptionCurveLinear | 時間曲線函數,勻速 |函數
|轉場動畫相關的 ||
|:|
| UIViewAnimationOptionTransitionNone | 無轉場動畫 |
| UIViewAnimationOptionTransitionFlipFromLeft | 轉場從左翻轉 |
| UIViewAnimationOptionTransitionFlipFromRight | 轉場從右翻轉 |
| UIViewAnimationOptionTransitionCurlUp | 上卷轉場 |
| UIViewAnimationOptionTransitionCurlDown | 下卷轉場 |
| UIViewAnimationOptionTransitionCrossDissolve | 轉場交叉消失 |
| UIViewAnimationOptionTransitionFlipFromTop | 轉場從上翻轉 |
| UIViewAnimationOptionTransitionFlipFromBottom | 轉場從下翻轉 |佈局