2012-05-31 4 views
1

저는 360도 뷰를 회전시키고 있지만 360도 회전시킬 수없는 앱을 개발 중입니다. 그것은 180도 회전하고 다시오고있다 회전하기 후 즉3D로보기를 360도 회전하는 방법은 무엇입니까?

animation = [CABasicAnimation animationWithKeyPath:@"transform"]; 
transform = CATransform3DMakeRotation(3.14f, 1.0f, 1.0f, 1.0f); 
value = [NSValue valueWithCATransform3D:transform]; 
[animation setToValue:value]; 
[animation setAutoreverses:YES]; 
[animation setDuration:0.9]; 
[[rotatBall layer] addAnimation:animation forKey:@"180"]; //rotatBall is a view 

, 그것은 회전 앞뒤로하고있다 .. 원래의 위치입니다지고 있습니다. 지속적으로 회전하는 방법 .... 친절하게 도와 ...

답변

0

조금 까다 롭지 만 docs에서 찾을 수 있습니다.
연속적으로 회전하려면 toValue을 설정 한 다음 애니메이션 반복 횟수를 HUGH_VALF (math.h에 정의 됨)으로 설정해야합니다.

CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"]; 

    transform = CATransform3DMakeRotation(1.0f, 1.0f, 1.0f, 1.0f); 
    fromValue = [NSValue valueWithCATransform3D:transform]; 

    transform = CATransform3DMakeRotation(M_PI*2, 1.0f, 1.0f, 1.0f); 
    toValue = [NSValue valueWithCATransform3D:transform]; 

    animation.fromValue = fromValue; 
    animation.toValue = toValue; 
    animation.duration = 0.9f; 
    animation.repeatCount = HUGE_VALF;  // HUGE_VALF is defined in math.h so import it 
    [rotatBall.layer addAnimation:animation forKey:@"rotation"]; 
0

당신이 YESautoreverses를 설정하기 때문에이 끝난 후 애니메이션이 반전됩니다. 그것이 바로 autoreverses입니다.

360 대신 360도 회전하는 이유는 무엇입니까?

+0

2 라디안하지만 난 2를 쓰고 때마다 심지어 당신이 할 수 있습니다 –

+0

이동하지 않습니다 [수학을 점검] (http://www.google.com/search?q=how+many+radians+ + 360도). 또한 상수'M_PI'가 도움이 될 수도 있습니다. – rickster

+0

나는 180 * 2를 의미했다 ... 심지어 6.28을 썼다. –

관련 문제