标签:color os ar line size app ad ef
UILabel *textlab = [[UILabel alloc]initWithFrame:CGRectMake(20, 10,ScrollView.frame.size.width - 40,260)];
textlab.text = @"测试用的随便写写ffffffffeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
textlab.backgroundColor = [UIColor clearColor];
textlab.textColor = [UIColor blackColor];
/* 设置字号大小*/
textlab.font = [UIFont systemFontOfSize:16.0];
textlab.textAlignment = NSTextAlignmentLeft;
/* 字符串太长自动换行 */
textlab.numberOfLines = 0;
textlab.lineBreakMode =NSLineBreakByWordWrapping;
//添加此项可以设置自适应
CGSize size = CGSizeMake(280,2000);//宽度高度上限
CGSize labelsize = [textlab.text sizeWithFont:textlab.font constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping];
[textlab setFrame:CGRectMake(20, 20, labelsize.width, labelsize.height)];
[ScrollView addSubview:textlab];
UILable自适应frame,布布扣,bubuko.com
标签:color os ar line size app ad ef
原文地址:http://www.cnblogs.com/XCoderLiu/p/3897532.html