日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

CoreAnimation--CALayer的动画

發布時間:2025/7/25 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CoreAnimation--CALayer的动画 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

CoreAnimation--CALayer的動畫

?

核心動畫中所有類都遵守CAMediaTiming

CAAnaimation和CAPropertyAnimation都是抽象類,本身不具備動畫效果,必須用它的子類才有動畫效果。

CAAnimationGroup是個動畫組,可以同時進行縮放,旋轉。

CABasicAnimation基本動畫,做一些簡單效果。

CAKeyframeAnimation幀動畫,做一些連續的流暢的動畫。

CATransition是轉場動畫,界面之間跳轉都可以用轉場動畫。

?

ios layer 動畫-(transform.scale篇)??

?

x軸縮放:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale.x"];
theAnimation.duration=8;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:1];
theAnimation.toValue = [NSNumber numberWithFloat:0.5];
?[yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

y軸縮放:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale.y"];
theAnimation.duration=8;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:1];
theAnimation.toValue = [NSNumber numberWithFloat:0.5];
?[yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

x軸,y軸同時按比例縮放:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
theAnimation.duration=8;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:1];
theAnimation.toValue = [NSNumber numberWithFloat:0.5];
?[yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

以上縮放是以view的中心點為中心縮放的,如果需要自定義縮放點,可以設置卯點:
//中心點
[yourView.layer setAnchorPoint:CGPointMake(0.5, 0.5)];

//左上角
[yourView.layer setAnchorPoint:CGPointMake(0, 0)];

//右下角
[yourView.layer setAnchorPoint:CGPointMake(1, 1)];

ios layer 動畫-(transform.rotation篇) ?

x軸旋轉:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
theAnimation.duration=8;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:0];
theAnimation.toValue = [NSNumber numberWithFloat:3.1415926];
?[yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

y軸旋轉:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
theAnimation.duration=8;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:0];
theAnimation.toValue = [NSNumber numberWithFloat:3.1415926];
?[yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

z軸旋轉:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
theAnimation.duration=8;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:0];
theAnimation.toValue = [NSNumber numberWithFloat:3.1415926];
?[yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

以上縮放是以view的中心點為中心縮放的,如果需要自定義縮放點,可以設置卯點:
//中心點
[yourView.layer setAnchorPoint:CGPointMake(0.5, 0.5)];

//左上角
[yourView.layer setAnchorPoint:CGPointMake(0, 0)];

//右下角
[yourView.layer setAnchorPoint:CGPointMake(1, 1)];

可設參數:

theAnimation.repeatCount = 0;
theAnimation.autoreverses = NO;


旋轉的另一種實現:(以下代碼繞z軸旋轉180度)
??? [self.topViewController.view.layer setAnchorPoint:CGPointMake(0.5, 0.5)];
??? [self.topViewController.view.layer setTransform:CATransform3DMakeRotation(0, 0, 0, 1)];
??? [UIView animateWithDuration:8 delay:0.0f options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseIn animations:^{
??????? [self.topViewController.view.layer setTransform:CATransform3DMakeRotation(3.1415926, 0, 0, 1)];
??? } completion:^(BOOL finished) {
??? }];

?

?

CATransition 過渡動畫 ?

?

??? CATransition *animation = [CATransition animation];

??? animation.duration = 0.3;

??? animation.type = @"cube"; ?//轉場動畫type見后文

??? animation.subtype = kCATransitionFromLeft;

??? [[self.tableView layer] addAnimation:animation forKey:@"myAnimation"];

?

  animation.fillMode = kCAFillModeBackwards;
  animation.startProgress = 0.01;
  animation.endProgress = 0.99;
使用過渡動畫,實現在同一個view上,左推,右推等各種動畫,節省一個view;

?

參數說明:

setType:可以返回四種類型:

  kCATransitionFade淡出

  kCATransitionMoveIn覆蓋原圖

  kCATransitionPush推出

  kCATransitionReveal底部顯出來

setSubtype:也可以有四種類型:

  kCATransitionFromRight;

  kCATransitionFromLeft(默認值)

  kCATransitionFromTop;

  kCATransitionFromBottom

?

[animation setType:@"type類型"];?可用的type類型主要有:

  pageCurl 向上翻一頁

  pageUnCurl 向下翻一頁

  rippleEffect 滴水效果

  suckEffect 收縮效果,如一塊布被抽走

  cube 立方體效果

  oglFlip 上下翻轉效果

?

/** 轉場動畫type一覽表 **/

fade?交叉淡化過渡

push?新視圖把舊視圖推出去

moveIn?新視圖移到舊視圖上面

reveal?將舊視圖移開,顯示下面的新視圖

cube?立方體翻滾效果?

oglFlip?上下左右翻轉效果

suckEffect?收縮效果,如一塊布被抽走

rippleEffect?水滴效果

pageCurl ?向上翻頁效果

pageUnCurl ?向下翻頁效果?

cameraIrisHollowOpen?相機鏡頭打開效果

cameraIrisHollowClose?相機鏡頭關閉效果

?

?

轉自:http://blog.163.com/it__man/blog/static/137199904201301722556447/

?

?

?

轉載于:https://www.cnblogs.com/stevenwuzheng/p/5543106.html

總結

以上是生活随笔為你收集整理的CoreAnimation--CALayer的动画的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。