【问题标题】:Setting repeatCount to 1e100f gives a warning将 repeatCount 设置为 1e100f 会发出警告
【发布时间】:2011-09-14 03:32:46
【问题描述】:

来自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

我做错了什么?

【问题讨论】:

  • Googol 文档看起来不太正确。提交错误报告,看看 Apple 是否知道无限循环的正确方法。

标签: ios xcode core-animation caanimation


【解决方案1】:

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

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

【讨论】:

  • 似乎有效,但我不会坐在椅子上等待。
【解决方案2】:

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

【讨论】:

  • 摆脱你的警告,它应该是一个浮点值
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-06-25
  • 2017-01-12
  • 1970-01-01
  • 2011-03-15
  • 1970-01-01
  • 2023-04-08
  • 1970-01-01
相关资源
最近更新 更多