2011-01-03 18 views

Odpowiedz

24

Spróbuj animation.repeatCount = HUGE_VALF;

+8

Float.infinity w Swift –

7

Z dokumentacji dla protokołu CAMediaTiming:

Ustawienie tej właściwości HUGE_VALF spowoduje animację powtarzania zawsze.

39

Można również użyć

animation.repeatCount = INFINITY; 

To jest dokładnie taka sama jak HUGE_VALF, ale wolę INFINITY jak to mówi o sobie.

+3

Float.infinity in Swift –

2

Po prostu przejdź do definicji!
Nie ma znaczenia, co to będzie: HUGE_VALF lub INFINITY.
Ponieważ:

(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 

i wreszcie (według math.c):

/* FUNCTION: __builtin_huge_valf */ 
inline float __builtin_huge_valf(void) { return 1.0f/0.0f; } 

więc każda opcja będzie ok:

animation.repeatCount = INFINITY; 
animation.repeatCount = HUGE_VALF; 
animation.repeatCount = __builtin_huge_valf(); 
animation.repeatCount = 1.0f/0.0f; 
2

W Swift używam następującego kodu:

let animation = CATransition() 
animation.repeatCount = Float.infinity 
Powiązane problemy