如何在Label中显示图片

来源:互联网 发布:javascript hide div 编辑:程序博客网 时间:2024/05/16 07:00
UIImage *image = [UIImage imageNamed:@"321.jpg"];
 
// 1> 生成文本附件
NSTextAttachment *textAttach = [[NSTextAttachment alloc] init];
textAttach.image = image;
 
// 2> 使用文本附件创建属性文本
NSAttributedString *strA = [NSAttributedString attributedStringWithAttachment:textAttach];
 
self.lblChat.attributedText = strA;
0 0
原创粉丝点击