標籤: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的行間距