#### 代码实现

1. 缩放 .我们可以看出每个圆形的缩放比例是经历了 `1,0.4,1` 这三个阶段,当然你也可以理解为 `0.4,1,0.4` ,至于为什么是0.4,仅仅是觉的比较好看Orz,并且我们定义动画完成一个循环需要的时间是1s.
2. 透明渐变 . 每个圆形的opacity属性经历了 `1,0.3,1` 这三个阶段,同上选中 `0.3,1,0.3` 也取决于你的喜好,同样的一个循环时间为1s.
``//scale - (CAKeyframeAnimation *)scaleAnimation {     CAKeyframeAnimation *scaleAnimate = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];     scaleAnimate.keyTimes = @[@0, @0.5, @1];     scaleAnimate.values = @[@1, @0.4, @1];     scaleAnimate.duration = kDuration;     return scaleAnimate; }  //opactity - (CAKeyframeAnimation *)opactityAnimation {     CAKeyframeAnimation *opacityAnimaton = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];     opacityAnimaton.keyTimes = @[@0, @0.5, @1];     opacityAnimaton.values = @[@1, @0.3, @1];     opacityAnimaton.duration = kDuration;     return opacityAnimaton; } ``

``CAAnimationGroup *animation = [[CAAnimationGroup alloc] init];       animation.animations = @[[self scaleAnimation], [self opactityAnimation]];     animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];     animation.duration = 1.f;     animation.repeatCount = HUGE;     animation.removedOnCompletion = NO; ``

``    for (int i = 0; i < 8; i++) {         CALayer *circle = [self circleLayerWithAngle:M_PI_4 * i size:circleSize origin:CGPointMake(x, y) containerSize:size color:tintColor];          animation.beginTime = beginTime + i * 0.12;         [circle addAnimation:animation forKey:@"animation"];         [layer addSublayer:circle];     }    - (CALayer *)circleLayerWithAngle:(CGFloat)angle size:(CGFloat)size origin:(CGPoint)origin containerSize:(CGSize)containerSize  color:(UIColor *)color{     CGFloat raduis = containerSize.width * 0.5;      CAShapeLayer *layer = [CAShapeLayer layer];     UIBezierPath *path = [[UIBezierPath alloc] init];      [path addArcWithCenter:CGPointMake(size * 0.5, size * 0.5) radius:size * 0.5 startAngle:0 endAngle:M_PI * 2 clockwise:NO];     [path closePath];     layer.fillColor = color.CGColor;     layer.path = path.CGPath;      CGRect frame = CGRectMake(origin.x + raduis * (cos(angle) + 1),                               origin.y + raduis * (sin(angle) + 1),                               size, size);     layer.frame = frame;     return layer; } ``

ps:为什么博客上传完gif的显示位置偏到姥姥家去了o.o