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

Idr*_*raf 4 iphone ios

我想在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];
Run Code Online (Sandbox Code Playgroud)

Kaa*_*glu 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];
Run Code Online (Sandbox Code Playgroud)

类似地,您可以使用CGAffineTransformMakeScale(x, y);- x中的值是水平刻度常量,y是垂直刻度值.请享用!!