标签:
NSString* text = @"一";
NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:16]};
CGSize size = [text boundingRectWithSize:CGSizeMake(1000, 90) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
CGFloat w = size.width+2;//一个汉字的宽度加2 ,要不然会显示残缺
text = @"如题,我们平时习惯的用法是将text以左右顺序呈现在UILabel上,那么有什么方法能让text以上下的顺序显示呢? ";
// CGSize asize = [text sizeWithFont:font constrainedToSize:CGSizeMake(w, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
//老的方法已经弃用了。
CGSize asize = [text boundingRectWithSize:CGSizeMake(w, MAXFLOAT) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:attribute context:nil].size;
CGFloat h = asize.height;
UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(100,10,w,h)];
lable.text = text;
lable.numberOfLines = 0;
[self.view addSubview:lable];
标签:
原文地址:http://www.cnblogs.com/yujinzhong/p/5848632.html