UIImage *image = [UIImage imageNamed:@"123.jpg"];
// 1> 生成文本附件
NSTextAttachment *textAttach = [[NSTextAttachment alloc] init];
textAttach.image = image;
textAttach.bounds=CGRectMake(0, -10, 20, 20);
// 2> 使用文本附件创建属性文本
NSMutableAttributedString *resultText = [[NSMutableAttributedString alloc] initWithString:result attributes:nil];
NSAttributedString *strB = [NSAttributedString attributedStringWithAttachment:textAttach];
labelc.textColor = [UIColor redColor];
[resultText insertAttributedString:strB atIndex:3];
labelc.attributedText = resultText;
UILabel加载图片
最新推荐文章于 2021-09-03 17:17:27 发布