【发布时间】:2011-01-05 12:25:00
【问题描述】:
我有以下代码:
desc = [[UILabel alloc] initWithFrame:CGRectMake(134, 5, 185, 60)];
[desc setNumberOfLines:20];
[dataView addSubview:desc];
desc.text =@"1111\n2222\n3333\n4444\n5555\n6666\n7777\n8888" ;
数据不适合标签,所以我看到如下内容:
1111
2222
3333
4444...
我还有一个按钮,当您单击它时,我想展开标签,以便所有数据都可见。为此,我有以下代码:
CGSize newDescSize = [desc.text sizeWithFont:[UIFont italicSystemFontOfSize:12] constrainedToSize:CGSizeMake(185, 400)];
[UIView beginAnimations:@"expandDesc" context:nil];
[UIView setAnimationDuration:1.0];
CGRect frame = desc.frame;
frame.size.height=newDescSize.height;
desc.frame=frame;
[UIView commitAnimations];
除了动画从视图开始之外,它工作正常:
3333
4444
5555
6666
在展开的同时在底部和顶部添加两条线,所以动画不流畅,我希望文本从原始文本扩展并在底部添加线。
有谁知道我做错了什么?
【问题讨论】:
标签: iphone objective-c animation uilabel