iOS之CAReplicatorLayer屬性簡介和使用

來源:互聯網
上載者:User

標籤:image   tco   cti   nsvalue   簡單   available   screen   dma   cgpoint   

1、CAReplicatorLayer簡介

  CAReplicatorLayer用於對圖層進行複製,包括圖層的動畫也能複製!可以看著將某一段事務進行重複!

#import <QuartzCore/CALayer.h>NS_ASSUME_NONNULL_BEGINCA_CLASS_AVAILABLE (10.6, 3.0, 9.0, 2.0)@interface CAReplicatorLayer : CALayer//指定圖層重複製多少次@property NSInteger instanceCount;//設定為YES,圖層將保持於CATransformLayer類似的性質和相同的限制@property BOOL preservesDepth;//複製延時,一般用在動畫上@property CFTimeInterval instanceDelay;//3D變換@property CATransform3D instanceTransform;//設定多個複製圖層的顏色,預設位白色@property(nullable) CGColorRef instanceColor;//設定每個複製圖層相對上一個複製圖層的紅色、綠色、藍色、透明度位移量@property float instanceRedOffset;@property float instanceGreenOffset;@property float instanceBlueOffset;@property float instanceAlphaOffset;@endNS_ASSUME_NONNULL_END

 

2、CAReplicatorLayer的簡單使用

- (void)cirAction{    CAShapeLayer *sharLayer = [CAShapeLayer layer];    sharLayer.backgroundColor = [UIColor redColor].CGColor;    sharLayer.bounds = CGRectMake(0, 0, 20, 20);    sharLayer.position = CGPointMake(CScreenWidth/2, 150);    sharLayer.cornerRadius = 10;        CABasicAnimation *ani = [CABasicAnimation animationWithKeyPath:@"transform"];    ani.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(10, 10, 1)];    ani.duration = 2;        CABasicAnimation *ani1 = [CABasicAnimation animationWithKeyPath:@"opacity"];    ani1.fromValue = @1;    ani1.toValue = @0;    ani1.duration = 2;        CAAnimationGroup *group = [CAAnimationGroup animation];    group.animations = @[ani,ani1];    group.duration = 2;    group.repeatCount = HUGE;    [sharLayer addAnimation:group forKey:nil];        CAReplicatorLayer *replayer  =[CAReplicatorLayer layer];    [replayer addSublayer:sharLayer];    replayer.instanceCount = 3;    replayer.instanceDelay = 0.5;    [self.showView.layer addSublayer:replayer];}

 

- (void)alphaAction{    CAShapeLayer *shapeLayer = [CAShapeLayer layer];    shapeLayer.backgroundColor = [UIColor redColor].CGColor;    shapeLayer.bounds = CGRectMake(0, 0, 50, 50);    shapeLayer.position = CGPointMake(CScreenWidth/2, 50);    shapeLayer.borderColor = [UIColor whiteColor].CGColor;    shapeLayer.cornerRadius = 25;    shapeLayer.borderWidth = 1;    shapeLayer.transform = CATransform3DMakeScale(.0, .0, .0);    CABasicAnimation *ani = [CABasicAnimation animationWithKeyPath:@"transform"];    ani.duration = 2;    ani.repeatCount = HUGE;    ani.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 1, 1)];    ani.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(.1, .1, .1)];    [shapeLayer addAnimation:ani forKey:nil];    CAReplicatorLayer *repLayer = [CAReplicatorLayer layer];    repLayer.frame = CGRectMake(0, 0, CScreenWidth, 300);    [repLayer addSublayer:shapeLayer];    repLayer.instanceCount = 20;    repLayer.instanceDelay = .1;    repLayer.instanceTransform = CATransform3DMakeRotation(M_PI/10, 0, 0, 1);    repLayer.instanceAlphaOffset = -0.05;    [self.showView.layer addSublayer:repLayer];}

 

 

 

iOS之CAReplicatorLayer屬性簡介和使用

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.