Label计算高度
UILabel *gettingSizeLabel = [[UILabel alloc] init];
gettingSizeLabel.font = [UIFont fontWithName:@"YOUR FONT's NAME" size:16];
gettingSizeLabel.text = @"YOUR LABEL's TEXT";
gettingSizeLabel.numberOfLines = 0;
gettingSizeLabel.lineBreakMode = NSLineBreakByWordWrapping;
CGSize maximumLabelSize = CGSizeMake(310, 9999);
CGSize expectSize = [gettingSizeLabel sizeThatFits:maximumLabelSize];
Label显示图片
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
textAttachment.image = [CacheManager getCacheWithUrl:[searchText substringWithRange:result.range]];
[attributedString replaceCharactersInRange:result.range withAttributedString:attrStringWithImage];
return attributedString;