将repeatCount设置为1e100f会发出警告

时间:2011-09-14 03:32:47

标签: ios xcode core-animation caanimation

来自Apple Documentation

Setting the repeatCount to 1e100f will cause the animation to repeat until it is removed from the layer.

这是我的代码:

CABasicAnimation *flicker = [CABasicAnimation animationWithKeyPath:@"opacity"];
flicker.repeatCount = 1e100f;

Xcode发出警告:

Semantic Issue: Magnitude of floating-point constant too large for type 'float'; maximum is 1.7014116E+38

我做错了什么?

2 个答案:

答案 0 :(得分:10)

尝试使用HUGE_VALF(我认为是1e50f,但使用常量)。查找repeatCount告诉我们:

  

将此属性设置为HUGE_VALF将导致动画永远重复。

答案 1 :(得分:1)

更改flicker.repeatCount = 1e100f; 至 flicker.repeatCount = 1e100;