在一个label 中显示多行,并自动换行 (计算行的高度,text的长度,大小等。)

EventAddresslabel=[[UILabel alloc]initWithFrame:CGRectMake(starttimelabel.frame.origin.x, starttimelabel.frame.origin.y+distance27020)];

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.height32060)];

DescriptionactivityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

DescriptionactivityView.frame = CGRectMake(140.fEventAddresslabel.frame.origin.y+3030.0f,30.0f);

Londinglabel_1=[[UILabel alloc]initWithFrame:CGRectMake(132Description.frame.origin.y+3080,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];

你可能感兴趣的:(iOS)