亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

iOS漸變圓環(huán)旋轉(zhuǎn)動畫CAShapeLayer CAGradientLayer

 更新時間:2016年09月20日 11:02:08   作者:Eric__li  
這篇文章主要介紹了iOS漸變圓環(huán)旋轉(zhuǎn)動畫CAShapeLayer CAGradientLayer的相關(guān)資料,需要的朋友可以參考下

iOS漸變圓環(huán)旋轉(zhuǎn)動畫CAShapeLayer CAGradientLayer

shape.gif

demo.png

- (void)viewDidLoad {
 [super viewDidLoad];
 // Do any additional setup after loading the view, typically from a nib.

 CALayer *layer = [CALayer layer];
 layer.backgroundColor = [UIColor redColor].CGColor; //圓環(huán)底色
 layer.frame = CGRectMake(100, 100, 110, 110);


 //創(chuàng)建一個圓環(huán)
 UIBezierPath *bezierPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(55, 55) radius:50 startAngle:0 endAngle:M_PI*2 clockwise:YES];

 //圓環(huán)遮罩
 CAShapeLayer *shapeLayer = [CAShapeLayer layer];
 shapeLayer.fillColor = [UIColor clearColor].CGColor;
 shapeLayer.strokeColor = [UIColor redColor].CGColor;
 shapeLayer.lineWidth = 5;
 shapeLayer.strokeStart = 0;
 shapeLayer.strokeEnd = 0.8;
 shapeLayer.lineCap = @"round";
 shapeLayer.lineDashPhase = 0.8;
 shapeLayer.path = bezierPath.CGPath;

 //顏色漸變
 NSMutableArray *colors = [NSMutableArray arrayWithObjects:(id)[UIColor redColor].CGColor,(id)[UIColor whiteColor].CGColor, nil];
 CAGradientLayer *gradientLayer = [CAGradientLayer layer];
 gradientLayer.shadowPath = bezierPath.CGPath;
 gradientLayer.frame = CGRectMake(50, 50, 60, 60);
 gradientLayer.startPoint = CGPointMake(0, 1);
 gradientLayer.endPoint = CGPointMake(1, 0);
 [gradientLayer setColors:[NSArray arrayWithArray:colors]];
 [layer addSublayer:gradientLayer]; //設(shè)置顏色漸變
 [layer setMask:shapeLayer]; //設(shè)置圓環(huán)遮罩
 [self.view.layer addSublayer:layer];

 //動畫
 CABasicAnimation *scaleAnimation1 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
 scaleAnimation1.fromValue = [NSNumber numberWithFloat:1.0];
 scaleAnimation1.toValue = [NSNumber numberWithFloat:1.5];
 scaleAnimation1.autoreverses = YES;
// scaleAnimation1.fillMode = kCAFillModeForwards;
 scaleAnimation1.duration = 0.8;

 CABasicAnimation *rotationAnimation2 = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
 rotationAnimation2.fromValue = [NSNumber numberWithFloat:0];
 rotationAnimation2.toValue = [NSNumber numberWithFloat:6.0*M_PI];
 rotationAnimation2.autoreverses = YES;
// scaleAnimation.fillMode = kCAFillModeForwards;
 rotationAnimation2.repeatCount = MAXFLOAT;
 rotationAnimation2.beginTime = 0.8; //延時執(zhí)行,注釋掉動畫會同時進行
 rotationAnimation2.duration = 2;


 //組合動畫
 CAAnimationGroup *groupAnnimation = [CAAnimationGroup animation];
 groupAnnimation.duration = 4;
 groupAnnimation.autoreverses = YES;
 groupAnnimation.animations = @[scaleAnimation1, rotationAnimation2];
 groupAnnimation.repeatCount = MAXFLOAT;
 [layer addAnimation:groupAnnimation forKey:@"groupAnnimation"];

}

- (void)didReceiveMemoryWarning {
 [super didReceiveMemoryWarning];
 // Dispose of any resources that can be recreated.
}
@end

關(guān)鍵的地方在于CABasicAnimation對象的初始化方式中keyPath的設(shè)定。在iOS中有以下幾種不同的keyPath,代表著不同的效果:

以上就是iOS漸變圓環(huán)旋轉(zhuǎn)動畫 的資料整理,后續(xù)繼續(xù)補充相關(guān)資料,謝謝大家對本站的支持!

相關(guān)文章

  • Objective-C?入門篇(推薦)

    Objective-C?入門篇(推薦)

    由C語言和Smalltalk擴展出來的,是C語言的超集,最大的區(qū)別是OC是面向?qū)ο蟮?,其火星文寫法對于之前從事Java開發(fā)的同學頗感蛋疼,OC最大特點之一是使用消息結(jié)構(gòu)而不是函數(shù)調(diào)用
    2021-11-11
  • iOS中SQLite使用教程

    iOS中SQLite使用教程

    sqlite是嵌入式的和輕量級的sql數(shù)據(jù)庫。sqlite是由c實現(xiàn)的。廣泛用于包括瀏覽器(支持html5的大部分瀏覽器,ie除外)、ios、android以及一些便攜需求的小型web應用系統(tǒng)
    2016-03-03
  • iOS自定義相機功能

    iOS自定義相機功能

    這篇文章主要為大家詳細介紹了iOS自定義相機功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • iOS 11 UINavigationItem 去除左右間隙的方法

    iOS 11 UINavigationItem 去除左右間隙的方法

    本篇文章主要介紹了iOS 11 UINavigationItem 去除左右間隙的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-10-10
  • 百度地圖PC端判斷用戶是否在配送范圍內(nèi)

    百度地圖PC端判斷用戶是否在配送范圍內(nèi)

    在pc端設(shè)置商家的配送范圍,用戶在下單時,根據(jù)用戶設(shè)置的配送地點判斷是否在可配送范圍內(nèi),并給用戶相應的提示,下面通過本文給大家分享具有實現(xiàn)代碼,感興趣的朋友一起學習吧
    2016-01-01
  • iOS整個APP實現(xiàn)灰色主題的示例代碼

    iOS整個APP實現(xiàn)灰色主題的示例代碼

    這篇文章主要介紹了iOS整個APP實現(xiàn)灰色主題的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-02-02
  • iOS對數(shù)組進行排序的實例代碼

    iOS對數(shù)組進行排序的實例代碼

    本文通過實例代碼給大家講解了ios對數(shù)組進行排序的實例方法,非常不錯,具有參考借鑒價值,需要的的朋友參考下吧
    2017-08-08
  • iOS UICollectionView實現(xiàn)標簽選擇器

    iOS UICollectionView實現(xiàn)標簽選擇器

    這篇文章主要為大家詳細介紹了iOS UICollectionView實現(xiàn)標簽選擇器,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-04-04
  • iOS中視頻播放器的簡單封裝詳解

    iOS中視頻播放器的簡單封裝詳解

    要實現(xiàn)封裝視頻播放器,首先需要實現(xiàn)視頻播放器,然后再去考慮怎樣封裝可以讓以后自己使用起來方便快捷。iOS9之前可以使用MediaPlayer來進行視頻的播放,iOS9之后系統(tǒng)推薦使用AVFoundation框架實現(xiàn)視頻的播放。下面通過本文來看看詳細的介紹吧。
    2016-10-10
  • ios 實現(xiàn)倒計時的兩種方式

    ios 實現(xiàn)倒計時的兩種方式

    這篇文章主要介紹了ios實現(xiàn)倒計時的兩種方式,第一種方式使用NSTimer來實現(xiàn),第二種方式使用GCD來實現(xiàn)。具體內(nèi)容詳情大家參考下本文
    2017-01-01

最新評論