标签:style io ar color os sp on div bs
//行高
#define kLineSpace 1.5
self.memo.text = self.ticketModel.memo;
//设置字体大小
self.memo.font = kFontSize(12);
//计算字体size
CGSize memoSize = [self.memo.textsizeWithFont:kFontSize(12) maxSize:CGSizeMake(260, MAXFLOAT)];
//计算加入行高后文字的高度
CGFloat linesH = (memoSize.height / 12 - 1) * kLineSpace;
//建立文本属性
NSMutableAttributedString *attributedString = [[NSMutableAttributedStringalloc] initWithString:self.memo.text];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStylealloc] init];
//调整行间距
[paragraphStyle setLineSpacing:kLineSpace];
[attributedString addAttribute:NSParagraphStyleAttributeNamevalue:paragraphStyle range:NSMakeRange(0, [self.memo.text length])];
self.memo.width = memoSize.width;
self.memo.height = linesH;
//设置文本属性
self.memo.attributedText = attributedString;
[ self.memo sizeToFit];
self.topView.height = CGRectGetMaxY(self.memo.frame) + 10;
self.myScrollView.contentSize = CGSizeMake(self.view.width, self.topView.height + 10);
ios 设置 UILabel的行间距
标签:style io ar color os sp on div bs
原文地址:http://www.cnblogs.com/xqios/p/4123784.html