画像ビューの 1 つの周りにグロー効果を生成する必要があります。そのために、shadowopacity プロパティを使用することにしました。
これが私のコードです:
imageViewForAnimation.layer.position = viewOrigin;
imageViewForAnimation.layer.shadowColor = [[UIColor yellowColor] CGColor];
imageViewForAnimation.layer.shadowOffset = CGSizeMake(0.0, 0.0);
imageViewForAnimation.layer.shadowRadius = 15.0;
imageViewForAnimation.layer.shadowOpacity = 0.3;
imageViewForAnimation.layer.masksToBounds = NO;
// Set up glow effect
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
anim.fromValue = [NSNumber numberWithFloat:0.0f];
anim.toValue = [NSNumber numberWithFloat:1.0f];
anim.duration = 3.0;
anim.repeatCount = HUGE_VALF;
anim.autoReverses = YES;
[imageViewForAnimation.layer addAnimation:anim forKey:@"shadowOpacity"];
imageViewForAnimation.layer.shadowPath = [UIBezierPath bezierPathWithRect:imageViewForAnimation.bounds].CGPath;
imageViewForAnimation.layer.shadowOpacity = 1.0f;
ただし、アニメーションは一度実行すると停止します。繰り返しはありません。誰でも理由がわかりますか?