2011-01-03 35 views

Trả lời

24

Hãy thử animation.repeatCount = HUGE_VALF;

+8

Float.infinity in Swift –

7

Từ các tài liệu cho các giao thức CAMediaTiming:

Thiết khách sạn này để HUGE_VALF sẽ gây ra các hình ảnh động để lặp lại mãi mãi.

39

Bạn cũng có thể sử dụng

animation.repeatCount = INFINITY; 

Đây là chính xác giống như HUGE_VALF, nhưng tôi thích INFINITY như nó nói của chính nó.

+3

Float.infinity in Swift –

2

Chỉ cần đi tới định nghĩa!
Không có vấn đề gì sẽ là: HUGE_VALF hoặc INFINITY.
Bởi vì:

(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 

và cuối cùng (theo math.c):

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

Vì vậy, mỗi tùy chọn sẽ là ok:

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

Trong Swift tôi đang sử dụng mã sau:

let animation = CATransition() 
animation.repeatCount = Float.infinity 
Các vấn đề liên quan