1
我需要围绕我的一个图像浏览产生辉光效果。为此,我决定使用shadowopacity属性。iOS 5:为什么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;
然而,动画只是运行一次后停止。没有重复。 任何人都可以看到为什么?
我已经在这里添加了这一行,但没有在我的代码中,这是问题: - )...无论如何你是对的。 Upvoted并标明正确。谢谢! –
很高兴我能帮到你。 – stringCode