iOS常用的一些動畫效果,UIView封裝的動畫,CALayer的動畫等

jopen 10年前發布 | 44K 次閱讀 UIView iOS開發 移動開發

1.UIView封裝的動畫
1> 首尾式
[UIView beginAnimations:nil context:nil];
// ... 需要執行怎樣的動畫
[UIView commitAnimations];

2> block [UIView animateWithDuration:0.5 animations:^{ // 需要執行的動畫 } completion:^(BOOL finished) { // 動畫完成 }];

3> 轉場動畫(過渡動畫) // 讓某個view執行轉場動畫 [UIView transitionWithView:<#(UIView *)#> duration:<#(NSTimeInterval)#> options:<#(UIViewAnimationOptions)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>];

2.CALayer的動畫 // CABasicAnimation和CAKeyframeAnimation的keyPath可以是哪些值? // 在xcode文檔搜索:CALayer Animatable Properties // transform的具體屬性:搜索catransform3d key path 1> CABasicAnimation

  • fromValue 初始值
  • toValue 最終值 (從初始化變化到最后某一個值)
  • byValue 步進值 (在初始值的基礎上,增加多少值)

2> CAKeyframeAnimation

  • values

3> CATransition(轉場動畫) CATransition *anim = [CATransition animation]; anim.type = @"cube"; anim.subtype = kCATransitionFromBottom; [view.layer addAnimation:anim forKey:nil];

4> CAAnimationGroup

  • 動畫,可以同時執行多個動畫

3.如何選擇動畫 1> 如果需要重復執行多次動畫,最好選擇CALayer動畫 2> 如果動畫執行完畢后,就要用到前面的一些東西,最好選擇UIView的block動畫 3> 如果需要同時執行多個動畫,最好選擇CAAnimationGroup 4> UIView動畫和CALayer動畫中最靈活的是CALayer的動畫

4.自定義一些動畫 用CADisplayLink,在刷幀方法完成需要執行的動畫</pre> 來自:http://blog.csdn.net/dylan_lwb_/article/details/39369495

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!