动画 UILabel 文本大小增大和减小



我想在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];

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 是垂直刻度常量。享受!!

它可能会帮助你

 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];

最新更新