2010-06-15 3 views
0

두 가지 애니메이션 방법이 있습니다. 기본적으로 그냥 반복합니다 ... 중복을 방지하고 깜박임을 방지하려면 어떻게해야합니까?iPhone에서 겹쳐지는 알파 페이드를 제어하는 ​​방법

감사합니다,

-(void) doPowerChangeAnimUp 
{ 
    powerIconChange .alpha = 0; 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:)]; 
    [UIView setAnimationDelegate:self] ; 
    [UIView setAnimationDuration:2]; 
    [powerIconChange setAlpha:1]; 
    [UIView commitAnimations]; 
} 

-(void)animationDidStop:(NSString *)animationID 
{ 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDelegate:self] ; 
    [UIView setAnimationDidStopSelector:@selector(doPowerChangeAnimUp)]; 
    [UIView setAnimationDuration:2]; 
    [powerIconChange setAlpha:0]; 
    [UIView commitAnimations]; 
} 
부드러운 "바운스"생성 할 수
+0

코드를 정리할 수 있습니까? 읽기 어려움 – Rudiger

답변

0

당신은 새로운 애니메이션을 만드는 대신 autoreverse하는 애니메이션 설정을 시도 할 수 있습니다 : 더욱

-(void) doPowerChangeAnimUp 
{ 
    powerIconChange .alpha = 0; 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationRepeatAutoreverses:YES]; 
    [UIView setAnimationRepeatCount:2]; 
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:)]; 
    [UIView setAnimationDelegate:self] ; 
    [UIView setAnimationDuration:2]; 
    [powerIconChange setAlpha:1]; 
    [UIView commitAnimations]; 
} 

를 대신 호출 did stop 선택기를 사용하면 animationRepeatCount을 더 높은 값으로 늘릴 수 있으므로 모든 애니메이션에 단일 beginAnimations 블록이 포함됩니다.

+0

좋아,하지만 이미 재생중인 애니메이션 인스턴스를 다시 만들지 않으려면 나에게 말해주는 BOOL이 있습니까? – ReduxDJ

관련 문제