我目前正在进行一个iPhone项目。我想在Objective-C中动态地扩大UILabel,就像这样:
这段代码的问题在于它不能动态地改变字体大小。
alt text http://img268.imageshack.us/img268/9683/bildschirmfoto20100323u.png
如何做到这一点?我以为我必须使用CoreAnimation,但是它没有起作用。这是我尝试过的代码:UILabel * fooL = //[…]
fooL.frame = CGRectMake(fooL.frame.origin.x, fooL.frame.origin.y, fooL.frame.size.width, fooL.frame.size.height);
fooL.font = [UIFont fontWithName:@"Helvetica" size:80];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
fooL.font = [UIFont fontWithName:@"Helvetica" size:144]; //bigger size
fooL.frame = CGRectMake(20 , 44, 728, 167); //bigger frame
[UIView commitAnimations];
这段代码的问题在于它不能动态地改变字体大小。