欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

iOS漸變圓環(huán)旋轉(zhuǎn)動(dòng)畫(huà)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)建一個(gè)圓環(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];

 //動(dòng)畫(huà)
 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; //延時(shí)執(zhí)行,注釋掉動(dòng)畫(huà)會(huì)同時(shí)進(jìn)行
 rotationAnimation2.duration = 2;


 //組合動(dòng)畫(huà)
 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對(duì)象的初始化方式中keyPath的設(shè)定。在iOS中有以下幾種不同的keyPath,代表著不同的效果:

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

相關(guān)文章

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

    Objective-C?入門(mén)篇(推薦)

    由C語(yǔ)言和Smalltalk擴(kuò)展出來(lái)的,是C語(yǔ)言的超集,最大的區(qū)別是OC是面向?qū)ο蟮模浠鹦俏膶?xiě)法對(duì)于之前從事Java開(kāi)發(fā)的同學(xué)頗感蛋疼,OC最大特點(diǎn)之一是使用消息結(jié)構(gòu)而不是函數(shù)調(diào)用
    2021-11-11
  • iOS中SQLite使用教程

    iOS中SQLite使用教程

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

    iOS自定義相機(jī)功能

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

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

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

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

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

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

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

    iOS對(duì)數(shù)組進(jìn)行排序的實(shí)例代碼

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

    iOS UICollectionView實(shí)現(xiàn)標(biāo)簽選擇器

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

    iOS中視頻播放器的簡(jiǎn)單封裝詳解

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

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

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

最新評(píng)論