gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 05:04:49 25 4
gpt4 key购买 nike

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

[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 是垂直比例常数。享受吧!!

关于iphone - 动画 UILabel 文本大小增加和减少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10696105/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com