1

来自苹果文档

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

我做错了什么?

4

2 回答 2

10

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

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

于 2011-09-14T06:57:30.947 回答
1

改变 flicker.repeatCount = 1e100f; 到 flicker.repeatCount = 1e100;

于 2013-05-09T09:20:33.590 回答