博客> 自定义转菊花
自定义转菊花
2019-12-10 23:02 评论:0 阅读:931 深山野猪
ios
_imageView.frame = CGRectMake(172, 200, 20, 20);
_imageView.backgroundColor = [UIColor orangeColor];
_imageView.layer.cornerRadius = 10;
_imageView.layer.masksToBounds = YES;
_imageView.layer.transform = CATransform3DMakeScale(0.01, 0.01, 0.01);
_imageView.alpha = 0;

CAReplicatorLayer *replicatorLayer = [CAReplicatorLayer layer];
replicatorLayer.bounds = self.view.bounds;
replicatorLayer.position = self.view.center;
replicatorLayer.preservesDepth = YES;
[replicatorLayer addSublayer:_imageView.layer];
[self.view.layer addSublayer:replicatorLayer];
_replicatorLayer = replicatorLayer;

CGFloat count = 15;
_replicatorLayer.instanceDelay = 1.0 / count;
_replicatorLayer.instanceCount = count;
_replicatorLayer.instanceTransform = CATransform3DMakeRotation((2 * M_PI) / count, 0, 0, 1.0);

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.duration = 1;
animation.repeatCount = MAXFLOAT;
animation.fromValue = @(1);
animation.toValue = @(0);

CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation2.duration = 1;
animation2.repeatCount = MAXFLOAT;
animation2.fromValue = @(1);
animation2.toValue = @(0);

CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.duration = 1;
animationGroup.repeatCount = MAXFLOAT;//HUGE_VALF;
[animationGroup setAnimations:[NSArray arrayWithObjects:animation,animation2, nil]];
[_imageView.layer addAnimation:animationGroup forKey:@"animationGroup"];
收藏
0
sina weixin mail 回到顶部