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

发布于 2024-12-04 14:08:28 字数 615 浏览 0 评论 0原文

来自 Apple 文档

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

我做错了什么?

From Apple Documentation:

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

Here's my code:

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

Xcode gives a warning:

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

Something I'm doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨巷深深 2024-12-11 14:08:28

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

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

Try using HUGE_VALF (which I think is 1e50f, but use the constant) instead. Looking up repeatCount tells us:

Setting this property to HUGE_VALF will cause the animation to repeat forever.

一世旳自豪 2024-12-11 14:08:28

更改 flicker.repeatCount = 1e100f;

闪烁.repeatCount = 1e100;

change flicker.repeatCount = 1e100f;
to
flicker.repeatCount = 1e100;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文