macOS-NSTextView显示图片
程序员文章站
2022-06-30 14:18:17
...
//NSTextView显示图片
NSTextAttachment *atacchment = [[NSTextAttachment alloc]init];
//用户的图片路径
atacchment.image = [NSImage imageNamed:@"a.png"] ;
//图片在textview中显示的大小
atacchment.bounds = CGRectMake(0, 0, 20, 20);
NSAttributedString *attributedStr = [[NSAttributedString alloc]initWithString:@""];
attributedStr = [NSAttributedString attributedStringWithAttachment:atacchment];
//textStorage装载内容的容器,继承自NSMutableAttributedString,其里面保存的东西决定了textview的富文本显示方式
[self.textView.textStorage appendAttributedString:attributedStr];
上一篇: 用平均的方法去除噪声
下一篇: 百度辟谣“李彦宏小三”传闻