4

我想在 UILabel 文本上应用动画。我编写代码以增加动画块中的字体大小,但未应用动画。

[UIView beginAnimations:nil context:nil/*contextPoint*/];
    monthsOnBoard.font=[UIFont fontWithName:@"digital-7" size:150];
    daysOnBoard.font=[UIFont fontWithName:@"digital-7" size:150];
    hoursOnBoard.font=[UIFont fontWithName:@"digital-7" size:100];
    minutesOnBoard.font=[UIFont fontWithName:@"digital-7" size:100];
    secondsOnBoard.font=[UIFont fontWithName:@"digital-7" size:100];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDelay:0.5];
    [UIView setAnimationDuration:1];
    [UIView setAnimationRepeatCount:4];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView commitAnimations];
4

2 回答 2

10

UIView 的字体不是动画属性。您应该改用转换。

[UIView beginAnimations:nil context:nil/*contextPoint*/];
monthsOnBoard.transform = CGAffineTransformMakeScale(2.0, 2.0); //increase the size by 2
 //etc etc same procedure for the other labels.
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:0.5];
[UIView setAnimationDuration:1];
[UIView setAnimationRepeatCount:4];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView commitAnimations];

同样,您可以使用以下值CGAffineTransformMakeScale(x, y);- x 是水平比例常数,y 是垂直比例常数。享受!!

于 2012-05-22T05:34:49.927 回答
1

可能对你有帮助

 monthsOnBoard.transform = CGAffineTransformScale(monthsOnBoard.transform, 1, 1); 
    [UIView beginAnimations:nil context:nil/*contextPoint*/];
    monthsOnBoard.transform = CGAffineTransformScale(monthsOnBoard.transform, 4, 4); 
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDelay:0.5];
    [UIView setAnimationDuration:1];
    [UIView setAnimationRepeatCount:4];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView commitAnimations];
于 2012-05-22T05:39:24.067 回答