2011-01-05 66 views
1

我試圖動畫一個UIImage視圖,每次順時針旋轉90度。 出於某種原因,第一個旋轉動畫可以工作,但隨後它會停止(即使其他視圖調整動畫大小繼續工作)。這是爲什麼? (我到處找也沒有找到答案)如何連續動畫UIImageView旋轉幾次

{ 
     [btn setFrame:CGRectMake(previousX, previousY, BUTTON_WIDTH, BUTTON_HEIGHT)]; 
     [self.view insertSubview:btn atIndex:0]; 

     [UIView beginAnimations:@"ButtonAnimation" context:nil]; 

     [UIView setAnimationDuration:2.5]; 

     [UIView setAnimationCurve:UIViewAnimationCurveLinear]; 

     CGRect rect = CGRectMake(previousX,previousY+BUTTON_HEIGHT,BUTTON_WIDTH,BUTTON_HEIGHT); 

     btn.frame = rect; 

     [UIView setAnimationBeginsFromCurrentState:YES]; 

     ++ButtonCounter; 
     if (ButtonCounter < [btnArray count]) 
      { 

       [UIView setAnimationDidStopSelector:@selector(didStopReal)]; 
      } 
      else 
      { 
       ButtonCounter = 0; 
      } 


     // The transform matrix 
     CGAffineTransform transform = 
     CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90)); 

     imgArrowView.transform = transform; 


     [UIView setAnimationDelegate:self]; 
     [UIView commitAnimations]; 
} 

-(void) didStopReal 
{ 
    [self animteReal:ButtonCounter]; 
} 

回答

3

建立你的親戚矩陣變換到當前變換:

CGAffineTransform transform = 
CGAffineTransformRotate(imgArrowView.transform, DEGREES_TO_RADIANS(90)); 
+0

謝謝,它的工作! – Idan 2011-01-05 13:51:04