2012-01-17 3 views
0

눈을 깜박이는 애니메이션을 임의의 간격으로 만들고 싶습니다. 정상적인 존재와 마찬가지로 무작위로 깜박입니다.임의 시간 간격. 눈 깜박임. UIView 통해 animateWithDuration :

그러나 이것은 내가 원하는 것, 어떤 생각이 아니 었나요?

- (void)animateFrogEyeOpenClose 
{ 
    if (OpenEye) { 
     [UIView animateWithDuration:0.1 

        animations:^{ 
         eyeOpenImageView.alpha = 0.0; 
         eyeCloseImageView.alpha = 1.0; 
        } 
        completion:^(BOOL completed){ 
         if (completed) 
          OpenEye = 0; 
          CloseEye = 1; 
          [self animateFrogEyeOpenClose];     
        }      
     ]; 
    } 
    else 
    { 
     [UIView animateWithDuration:0.1 

        animations:^{ 
         eyeOpenImageView.alpha = 1.0; 
         eyeCloseImageView.alpha = 0.0; 
        } 
        completion:^(BOOL completed){ 
         if (completed) 
          OpenEye = 1; 
         CloseEye = 0; 
          [self animateFrogEyeOpenClose];     
        }     
     ]; 
    } 
} 

답변

2

왜 임의의 시간 후에이 방법을 사용합니까? like

//call this method for the first time 
[self fireMethod:nil]; 
// 

- (void)fireMethod:(id)sender{ 
    int rand = arc4random(); //set the random no acc. to your requirement 
    [self animateFrogEyeOpenClose]; 
    [self performSelector:@selector(fireMthod:) withObject:nil afterDelay:rand]; 
} 
+0

감사합니다. 도움을 주셔서 감사합니다. – Desmond

+1

내 기쁨 .... –