2010-08-07 4 views
5

어떻게 회전합니까 OpenGL ES를 사용하지 않고 UIView, UIImageView 또는 CALayer 애니메이션 360도 degress?UIView, UIImageView 또는 CALayer 360도 애니메이션을 어떻게 회전합니까?

+3

당신은 360˚ 회전이 바로 당신에게 동일한 이미지를 줄 것이라는 점을 인식 할 수 있습니까? – SteamTrout

+0

내가 깨닫기 전에 내가 해결책을 생각하기 시작한 것은 슬픈 일이다. – jtbandes

+0

@Steam Trout : 순간적으로 만 원한다면. – JeremyP

답변

3

아마 360 °를 중심으로 UIImage 회전 애니메이션을 의미할까요? 내 경험에 의하면, 전체 원형 회전을 달성 할 수있는 방법은 체인입니다 다수의 애니메이션을 함께 : 당신은 각각의 애니메이션을 볼 수 있도록 내가 대신 (대신 선형)을 easeIn/easeOut 곡선을 ​​왼쪽으로 한

- (IBAction)rotate:(id)sender 
{ 
    [UIView beginAnimations:@"step1" context:NULL]; { 
     [UIView setAnimationDuration:1.0]; 
     [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 
     [UIView setAnimationDelegate:self]; 
    [imageView.transform = CGAffineTransformMakeRotation(120 * M_PI/180); 
    } [UIView commitAnimations]; 
} 

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 
{ 
    if ([animationID isEqualToString:@"step1"]) { 
     [UIView beginAnimations:@"step2" context:NULL]; { 
     [UIView setAnimationDuration:1.0]; 
     [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 
     [UIView setAnimationDelegate:self]; 
     imageView.transform = CGAffineTransformMakeRotation(240 * M_PI/180); 
     } [UIView commitAnimations]; 
    } 
    else if ([animationID isEqualToString:@"step2"]) { 
     [UIView beginAnimations:@"step3" context:NULL]; { 
     [UIView setAnimationDuration:1.0]; 
     [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 
     [UIView setAnimationDelegate:self]; 
     imageView.transform = CGAffineTransformMakeRotation(0); 
     } [UIView commitAnimations]; 
    } 
} 

.

28
#import <QuartzCore/QuartzCore.h> 

CABasicAnimation *fullRotation; 
fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 
fullRotation.fromValue = @(0.0); 
fullRotation.toValue = @((360.0 * M_PI)/180.0); 
fullRotation.duration = 3.5f; 
fullRotation.repeatCount = MAXFLOAT; 

[view.layer addAnimation:fullRotation forKey:@"rotation-animation"]; 

당신이 주위를 회전 할 수있는 기준점을 변경하려면 다음

CGRect frame = view.layer.frame; 
self.anchorPoint = CGPointMake(0.5, 0.5); // rotates around center 
self.frame = frame; 
관련 문제