CGSize textSize = CGSizeMake(mainView_w - 16, 1000);
if (optionType == YunChengOptionTypeYear) {
all_haulobj = [all_haulArray objectAtIndex:row];
} else {
all_haulobj = [all_haulArray2 objectAtIndex:row];
}
// tmpRect = [all_haulobj.content boundingRectWithSize:textSize options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:text_Font,NSFontAttributeName, nil] context:nil];
// return tmpRect.size.height + 19;
NSMutableAttributedString * str = [[NSMutableAttributedString alloc] initWithString:all_haulobj.content];
NSMutableParagraphStyle * paragraph = [[NSMutableParagraphStyle alloc]init];
[paragraph setLineSpacing:4];//设置行间距
[paragraph setAlignment:NSTextAlignmentLeft];//设置对齐方式
[str addAttribute:NSParagraphStyleAttributeName value:paragraph range:NSMakeRange(0, str.length)];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontWithHexOfSize:FYFont_T017] range:NSMakeRange(0, str.length)];
CGRect mycontentLabelRect = [str boundingRectWithSize:textSize options:(NSStringDrawingUsesLineFragmentOrigin) context:nil];
return mycontentLabelRect.size.height + 5;
记住最后的那个+5 在tableview用 一定要加5 否则 有些地方显示不完整
在tableview的label使用NSMutableAttributedString要注意
最新推荐文章于 2021-06-17 05:26:15 发布
