CABasicAnimation无限重复没有HUGE

编程入门 行业动态 更新时间:2024-10-21 04:08:42
CABasicAnimation无限重复没有HUGE_VALF?(CABasicAnimation unlimited repeat without HUGE_VALF?)

我试图用CABasicAnimation来执行我的图像旋转动画的自动重复。 我试图在网上搜索如何设置这样的属性,但无法找到。 CA动画真的没有这种属性吗? 我知道你可以设置一些巨大的值( 在这里 )repeatCount属性,但嘿,为什么然后UIView animateWithDuration有一个选项UIViewAnimationOptionRepeat和值硬编码为它?

I'm trying to perform auto repeat of my image rotation animation with CABasicAnimation. I have tried to search on web how to set such property but was unable to find that. Is it really no such property for CA animation? I know that you can set some huge value (here) to repeatCount property but hey, why then does UIView animateWithDuration has an option UIViewAnimationOptionRepeat and what the value is hardcoded for it?

最满意答案

不,这是你按照文档要做的方式。

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


Swift更新:

HUGE_VALF不暴露给Swift。 然而,我从这个页面了解到,HUGE_VALF是无限的(事实上, INFINITY被定义为HUGE_VALF )。 由于Swift的FloatingPointType协议提供了一个static var infinity ,你可以简单地写

myAnimation.repeatCount = .infinity

No, this is the way you're supposed to do it according to the documentation.

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


Update for Swift:

HUGE_VALF is not exposed to Swift. However, my understanding from this page is that HUGE_VALF is intended to be infinity (in fact, INFINITY is defined as HUGE_VALF). Since Swift's FloatingPointType protocol provides a static var infinity, you can simply write

myAnimation.repeatCount = .infinity

更多推荐

本文发布于:2023-08-07 20:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465576.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CABasicAnimation   HUGE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!