首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >增加和减小UILabel文本大小的动画

增加和减小UILabel文本大小的动画
EN

Stack Overflow用户
提问于 2012-05-22 13:21:38
回答 2查看 5.9K关注 0票数 4

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

代码语言:javascript
复制
[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];
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-05-22 13:34:50

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

代码语言:javascript
复制
[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是垂直刻度常数。享受吧!!

票数 10
EN

Stack Overflow用户

发布于 2012-05-22 13:39:24

它可能会对你有所帮助

代码语言:javascript
复制
 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];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10696105

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档