どうすればCAKeyframeAnimation
終わりのない繰り返し回数を持たせることができますか?
試しanimation.repeatCount = -1;
ましたが、1回しか繰り返されません。
どうすればCAKeyframeAnimation
終わりのない繰り返し回数を持たせることができますか?
試しanimation.repeatCount = -1;
ましたが、1回しか繰り返されません。
使用することもできます
animation.repeatCount = INFINITY;
これは HUGE_VALF とまったく同じですが、私は INFINITY が独力で話すので好きです。
試すanimation.repeatCount = HUGE_VALF;
CAMediaTimingプロトコルのドキュメントから:
このプロパティを に設定
HUGE_VALF
すると、アニメーションが永遠に繰り返されます。
Swift では、次のコードを使用しています。
let animation = CATransition()
animation.repeatCount = Float.infinity
定義に行くだけです!
HUGE_VALF か INFINITY かは関係ありません。
なぜなら:
(数学:)
#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
そして最後に(math.cによると):
/* FUNCTION: __builtin_huge_valf */
inline float __builtin_huge_valf(void) { return 1.0f/0.0f; }
したがって、各オプションは問題ありません。
animation.repeatCount = INFINITY;
animation.repeatCount = HUGE_VALF;
animation.repeatCount = __builtin_huge_valf();
animation.repeatCount = 1.0f/0.0f;