CABasicAnimation 脉冲效果

 1     UIImage *image = [UIImage imageNamed:@"heart.png"];
 2     CALayer *layer = [CALayer layer];
 3     layer.contents = (id)image.CGImage;
 4     layer.bounds = CGRectMake(0, 0, image.size.width, image.size.height);
 5     layer.position = CGPointMake(160, 200);
 6 
 7     layer.transform = CATransform3DMakeScale(0.90, 0.90, 1);  // 将图片大小按照X轴和Y轴缩放90%,永久
 8     [self.view.layer addSublayer:layer];
 9     
10     CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
11     animation.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity]; // 将目标值设为原值
12     animation.autoreverses = YES; // 自动倒回最初效果
13     animation.duration = 0.35;
14     animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
15     animation.repeatCount = HUGE_VALF;
16     [layer addAnimation:animation forKey:@"pulseAnimation"];
原文地址:https://www.cnblogs.com/sell/p/2909440.html