CAReplicatorLayer 重復(fù)圖層

以前看高級(jí)動(dòng)畫的時(shí)候,知道CAReplicatorLayer 重復(fù)圖層,沒怎么去用,今天看別人博客看到這個(gè),感覺挺適合做一些動(dòng)畫效果,于是自己嘗試一下,做了個(gè)簡(jiǎn)單動(dòng)畫。

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    CAReplicatorLayer *replicatiorLayer = [CAReplicatorLayer layer];
    replicatiorLayer.frame = CGRectMake(100, 64, 350 , 350);
    replicatiorLayer.position = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height / 2);
    replicatiorLayer.instanceCount= 16;
    replicatiorLayer.instanceTransform = CATransform3DMakeRotation(2 * M_PI / 16, 0, 0, 1);
    replicatiorLayer.instanceBlueOffset = -0.1;
    replicatiorLayer.instanceRedOffset = -0.1;
    replicatiorLayer.instanceDelay = 1.0 / 16; ;
    
    CALayer *layer = [CALayer layer];
    layer.anchorPoint = CGPointMake(0.0, 0.0);
    layer.frame = CGRectMake(80, 150, 30, 30);
    layer.cornerRadius  = 15;
    
    layer.backgroundColor = [UIColor colorWithRed:200/ 255.0 green:200/ 255.0 blue:244/ 255.0 alpha:1].CGColor;
    [replicatiorLayer addSublayer:layer];
    
    [self.view.layer addSublayer:replicatiorLayer];
    CABasicAnimation *baseAnimation = [CABasicAnimation animation];
    baseAnimation.keyPath = @"transform.scale";
    baseAnimation.fromValue = @(1.0);
    baseAnimation.toValue = @(0.1);
    baseAnimation.repeatCount = MAXFLOAT;
    baseAnimation.duration = 1.0;
    [layer addAnimation:baseAnimation forKey:@"baseAnimation"];
    
}
188.gif
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容