[Objective-C] 在一个label中显示多行,自动换行 →→→→→进入此内容的聊天室

来自 , 2020-07-02, 写在 Objective-C, 查看 141 次.
URL http://www.code666.cn/view/e32cc80b
  1. EventAddresslabel=[[UILabel alloc]initWithFrame:CGRectMake(starttimelabel.frame.origin.x,       starttimelabel.frame.origin.y+distance, 270, 20)];
  2. EventAddresslabel.backgroundColor=[UIColor clearColor];
  3. EventAddresslabel.textColor=[UIColor whiteColor];
  4. EventAddresslabel.font=[UIFont systemFontOfSize:15];
  5. 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.
  6. EventAddresslabel.lineBreakMode = UILineBreakModeWordWrap;// sys will change the line by word.aslo can be by character  for another value.
  7. EventAddresslabel.text=[NSString stringWithFormat:@"%@  %@,%@",cassetInfo.eventAddress,cassetInfo.city,cassetInfo.state];
  8. [uiview addSubview:EventAddresslabel];
  9.        
  10. CGSize EventAddresslabelsize = [EventAddresslabel.text sizeWithFont:[UIFont systemFontOfSize:15]        constrainedToSize:CGSizeMake(285, [EventAddresslabel.text length])lineBreakMode:UILineBreakModeWordWrap];
  11. [EventAddresslabel setFrame:CGRectMake(EventAddresslabel.frame.origin.x,EventAddresslabel.frame.origin.y,       290,EventAddresslabelsize.height+10)];
  12.  
  13. Description=[[UILabel alloc]initWithFrame:CGRectMake(5,EventAddresslabel.frame.origin.y+EventAddresslabel.frame.size.height, 320, 60)];
  14. DescriptionactivityView = [[UIActivityIndicatorView alloc]      initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
  15. DescriptionactivityView.frame = CGRectMake(140.f, EventAddresslabel.frame.origin.y+30, 30.0f,30.0f);
  16. Londinglabel_1=[[UILabel alloc]initWithFrame:CGRectMake(132, Description.frame.origin.y+30, 80,20)];
  17. Labelflag=0;
  18. Description.backgroundColor=[UIColor clearColor];
  19. Description.textColor=[UIColor whiteColor];
  20. Description.font=[UIFont systemFontOfSize:15];
  21. Description.numberOfLines =0;
  22. Description.lineBreakMode = UILineBreakModeWordWrap;
  23. [uiview addSubview:Description];
  24. //objectc/2000

回复 "在一个label中显示多行,自动换行"

这儿你可以回复上面这条便签

captcha