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

nin*_*eer 1 xcode core-animation caanimation ios

来自Apple文档:

Setting the repeatCount to 1e100f will cause the animation to repeat until it is removed from the layer.
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

CABasicAnimation *flicker = [CABasicAnimation animationWithKeyPath:@"opacity"];
flicker.repeatCount = 1e100f;
Run Code Online (Sandbox Code Playgroud)

Xcode发出警告:

Semantic Issue: Magnitude of floating-point constant too large for type 'float'; maximum is 1.7014116E+38
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

Cal*_*leb 10

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

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

  • 似乎工作,虽然我不会坐在椅子上等待. (2认同)