2014-03-12 30 views
0

我正在嘗試使用transform屬性爲UILabel設置動畫。它似乎在主動畫中運行良好。但是,一旦我嘗試動畫在主動畫完成塊CGAffineTransform無法在UIView動畫完成塊中工作

UILabel *dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(point.x, point.y, 50, 20)]; 
    dateLabel.text = [NSString stringWithFormat:@"%d", date]; 
    dateLabel.textColor = [UIColor whiteColor]; 
    dateLabel.textAlignment = NSTextAlignmentCenter; 
    [self addSubview:dateLabel]; 
    [UIView animateWithDuration:.4 animations:^{ 
     dateLabel.frame = CGRectMake(self.frame.size.width/2 - 25, 10, 50, 70); 
     self.calendar.frame = CGRectMake(0, 800, 320, 320); 
     dateLabel.font = [UIFont fontWithName:@"Bariol-Bold" size:28]; 
    } completion:^(BOOL finished) { 

     [UIView animateWithDuration:.5 animations:^{ 
      self.monthLabel.transform = CGAffineTransformMakeScale(1.2,1.2); 
      [self.monthLabel sizeToFit]; 
     } completion:nil]; 

     [UIView animateWithDuration:.5 animations:^{ 
      self.monthLabel.transform = CGAffineTransformMakeScale(1.15,1.15); 
      [self.monthLabel sizeToFit]; 
     } completion:nil]; 

     calendarAnimation = NO; 
    }]; 
+0

您正在該完成塊中同時運行兩個動畫。第二個不應該在第一個的完成塊中嗎? – jrturton

+0

只是試過,仍然沒有工作:( – user2752687

+0

sizeToFit電話應該不會真的在那裏,但我不知道他們會影響動畫。你是什麼意思「不工作」? – jrturton

回答

0

你不解釋什麼是錯的變換動畫。但在我的情況下,轉換不是動畫,它會轉換到最終狀態,好像持續時間是0.0。 我能夠通過添加選項來解決這個問題:

[UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionOverrideInheritedDuration|UIViewAnimationOptionOverrideInheritedCurve animations:^{ 
    // animate transform here 
    } completion:^(BOOL finished) { 
    // finished; 
}]; 

讓我知道,如果它幫助。