14

どうすればCAKeyframeAnimation終わりのない繰り返し回数を持たせることができますか?

試しanimation.repeatCount = -1;ましたが、1回しか繰り返されません。

4

5 に答える 5

41

使用することもできます

animation.repeatCount = INFINITY;

これは HUGE_VALF とまったく同じですが、私は INFINITY が独力で話すので好きです。

于 2011-02-21T15:26:20.750 に答える
26

試すanimation.repeatCount = HUGE_VALF;

于 2011-01-03T00:40:33.140 に答える
7

CAMediaTimingプロトコルのドキュメントから:

このプロパティを に設定HUGE_VALFすると、アニメーションが永遠に繰り返されます。

于 2011-01-03T00:42:38.147 に答える
5

Swift では、次のコードを使用しています。

let animation = CATransition()
animation.repeatCount = Float.infinity
于 2016-05-31T10:29:11.800 に答える
2

定義に行くだけです!
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;
于 2014-12-25T15:56:05.093 に答える