how can i make my CAKeyframeAnimation
have a never ending repeat count?
I tried animation.repeatCount = -1;
but it only repeats once.
how can i make my CAKeyframeAnimation
have a never ending repeat count?
I tried animation.repeatCount = -1;
but it only repeats once.
You can also use
animation.repeatCount = INFINITY;
This is exactly the same as HUGE_VALF, but I prefer INFINITY as it speaks by itself.
From the documentation for the CAMediaTiming protocol:
Setting this property to
HUGE_VALF
will cause the animation to repeat forever.
In Swift I'm using the following code:
let animation = CATransition()
animation.repeatCount = Float.infinity
Just go to definition!
There is no matter what it will be: either HUGE_VALF or INFINITY.
Because:
(math.h:)
#if defined(__GNUC__)
# define HUGE_VAL __builtin_huge_val()
# define HUGE_VALF __builtin_huge_valf()
# define HUGE_VALL __builtin_huge_vall()
# define NAN __builtin_nanf("0x7fc00000")
#else
# define HUGE_VAL 1e500
# define HUGE_VALF 1e50f
# define HUGE_VALL 1e5000L
# define NAN __nan()
#endif
#define INFINITY HUGE_VALF
and finally (according to math.c):
/* FUNCTION: __builtin_huge_valf */
inline float __builtin_huge_valf(void) { return 1.0f/0.0f; }
So each option will be ok:
animation.repeatCount = INFINITY;
animation.repeatCount = HUGE_VALF;
animation.repeatCount = __builtin_huge_valf();
animation.repeatCount = 1.0f/0.0f;