NSString文字高度计算,电话号码自动识别
CGFloat recordLeft = point.right + 18;
NSString * recordText = dic[@"processStatus"];
CGFloat textMaxW = SCREEN_WIDTH - recordLeft - kCellBorder + 16;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
[paragraphStyle setLineSpacing:5];
NSDictionary *attributes = @{ NSFontAttributeName:FONT(14), NSParagraphStyleAttributeName:paragraphStyle};
CGRect recordRect = [recordText boundingRectWithSize:CGSizeMake(textMaxW - 16, SIZE_MAX)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:attributes
context:nil];
//3.进程内容 (UITextView四周有8的边框,所以UITextView的宽是recordRect的宽+16 ,高是recordRect高度+16)
UITextView * record = [[UITextView alloc]initWithFrame:CGRectMake(recordLeft - 10, date.top - 8, textMaxW, recordRect.size.height + 16)];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:recordText];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, recordText.length)];
record.attributedText = attributedString;
record.editable = NO;
record.alwaysBounceVertical = NO;
record.scrollEnabled = NO;
record.font = FONT(14);
record.text = recordText;
//设置电话号码自动识别
record.dataDetectorTypes = UIDataDetectorTypePhoneNumber;
record.textColor = kColor_LightGray;
[self.scollView addSubview:record];