在一个label中显示多行,自动换行
2011-07-21 18:00
323 查看
在active.com的开发项目中,遇到一个动态显示detail page的问题。取的数据有的时候多有的时候少,而且还需要自动换行。计算行的高度,text的长度,大小等。EventAddresslabel=[[UILabel alloc]initWithFrame:CGRectMake(starttimelabel.frame.origin.x, starttimelabel.frame.origin.y+distance, 270, 20)];
EventAddresslabel.backgroundColor=[UIColor clearColor];
EventAddresslabel.textColor=[UIColor whiteColor];
EventAddresslabel.font=[UIFont systemFontOfSize:15];
EventAddresslabel.numberOfLines =0; //this is used to determine how many lines this label will have.if =3,it means this label's text will show 3 lines.if =0 ,it means that this label's text will show the line whate it needs.no limit.
EventAddresslabel.lineBreakMode = UILineBreakModeWordWrap;// sys will change the line by word.aslo can be by character for another value.
EventAddresslabel.text=[NSString stringWithFormat:@"%@ %@,%@",cassetInfo.eventAddress,cassetInfo.city,cassetInfo.state];
[uiview addSubview:EventAddresslabel];
CGSize EventAddresslabelsize = [EventAddresslabel.text sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(285, [EventAddresslabel.text length])lineBreakMode:UILineBreakModeWordWrap];
[EventAddresslabel setFrame:CGRectMake(EventAddresslabel.frame.origin.x,EventAddresslabel.frame.origin.y, 290,EventAddresslabelsize.height+10)];
Description=[[UILabel alloc]initWithFrame:CGRectMake(5,EventAddresslabel.frame.origin.y+EventAddresslabel.frame.size.height, 320, 60)];
DescriptionactivityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
DescriptionactivityView.frame = CGRectMake(140.f, EventAddresslabel.frame.origin.y+30, 30.0f,30.0f);
Londinglabel_1=[[UILabel alloc]initWithFrame:CGRectMake(132, Description.frame.origin.y+30, 80,20)];
Labelflag=0;
Description.backgroundColor=[UIColor clearColor];
Description.textColor=[UIColor whiteColor];
Description.font=[UIFont systemFontOfSize:15];
Description.numberOfLines =0;
Description.lineBreakMode = UILineBreakModeWordWrap;
[uiview addSubview:Description];
EventAddresslabel.backgroundColor=[UIColor clearColor];
EventAddresslabel.textColor=[UIColor whiteColor];
EventAddresslabel.font=[UIFont systemFontOfSize:15];
EventAddresslabel.numberOfLines =0; //this is used to determine how many lines this label will have.if =3,it means this label's text will show 3 lines.if =0 ,it means that this label's text will show the line whate it needs.no limit.
EventAddresslabel.lineBreakMode = UILineBreakModeWordWrap;// sys will change the line by word.aslo can be by character for another value.
EventAddresslabel.text=[NSString stringWithFormat:@"%@ %@,%@",cassetInfo.eventAddress,cassetInfo.city,cassetInfo.state];
[uiview addSubview:EventAddresslabel];
CGSize EventAddresslabelsize = [EventAddresslabel.text sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(285, [EventAddresslabel.text length])lineBreakMode:UILineBreakModeWordWrap];
[EventAddresslabel setFrame:CGRectMake(EventAddresslabel.frame.origin.x,EventAddresslabel.frame.origin.y, 290,EventAddresslabelsize.height+10)];
Description=[[UILabel alloc]initWithFrame:CGRectMake(5,EventAddresslabel.frame.origin.y+EventAddresslabel.frame.size.height, 320, 60)];
DescriptionactivityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
DescriptionactivityView.frame = CGRectMake(140.f, EventAddresslabel.frame.origin.y+30, 30.0f,30.0f);
Londinglabel_1=[[UILabel alloc]initWithFrame:CGRectMake(132, Description.frame.origin.y+30, 80,20)];
Labelflag=0;
Description.backgroundColor=[UIColor clearColor];
Description.textColor=[UIColor whiteColor];
Description.font=[UIFont systemFontOfSize:15];
Description.numberOfLines =0;
Description.lineBreakMode = UILineBreakModeWordWrap;
[uiview addSubview:Description];
相关文章推荐
- 在一个label中显示多行,自动换行
- 在一个label中显示多行,自动换行
- 在一个label 中显示多行,并自动换行 (计算行的高度,text的长度,大小等。)
- 在一个label中显示多行,自动换行
- vb 如何在Text文本框或Label里显示一个字符后自动换行
- vb 如何在Text文本框或Label里显示一个字符后自动换行
- 在一个label中显示多行
- 对CCLabelTTF进行自动换行,显示打字效果(转)
- 对CCLabelTTF进行自动换行,显示打字效果
- ireport报表制作, 当一个字段显示的数据太多时(数据过长),则需要自动换行
- EditText单行、多行和自动换行显示内容
- uilabel 的相关处理 类富文本(自动换行,设置行高,同一个label多种颜色,给文字加下划线 首行缩进 等 等)
- highcharts图表中级入门之xAxis label:X(横)坐标刻度值过长截断多行(换行)显示问题说明
- android中的textview显示汉字不能自动换行的一个解决办法
- elphi 怎么给字符串里加回车换行,label显示多行文本的两种方法
- 对CCLabelTTF进行自动换行,显示打字效果(转)
- html显示一个长的错误单词换行,内容自动换行
- C# Label显示多行文本及换行(WinForm/WebForm)
- 一个让label里字符串自动换行的属性
- C# Label显示多行文本及换行(WinForm/WebForm)