首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么不显示NSTextAttachment图像?

为什么不显示NSTextAttachment图像?
EN

Stack Overflow用户
提问于 2017-06-25 17:22:26
回答 1查看 736关注 0票数 1

我正在尝试将图像添加到属性字符串中:

代码语言:javascript
复制
NSTextAttachment *locationIcon = [[NSTextAttachment alloc] init];
locationIcon.image = [UIImage imageNamed:@"location-pin-icon"];
NSAttributedString *iconString = [NSAttributedString attributedStringWithAttachment:locationIcon];
[string appendAttributedString:iconString];
NSAttributedString *locationNameString = [[NSAttributedString alloc] initWithString:@"some text" attributes:linkAttributes];
[string appendAttributedString:locationNameString];

然后我只需设置myLabel.text = string; (其中myLabel是一个TTTAttributedLabel)

location-pin-icon是一个有效的镜像(我在调试时也检查过它)。但是,位置针图标没有显示在标签中(下面的“一些文本”显示得很好,而linkAttributes只是系统字体的集合,带有自定义的蓝色)。我也尝试过手动设置文本附件的边界,或者在文本前留一个空格,但似乎都不起作用。

我做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-11 23:18:51

这显然是由于TTTAttributedLabel的实现。图书馆好像坏了。当我从它切换时,附件开始正确显示。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44744963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档