![](/img/trans.png)
[英]NSTextAttachment image not displayed on iOS 8 devices (with iOS7.1 sdk)
[英]Why is NSTextAttachment image not displayed?
我正在尝试将图像添加到属性字符串:
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
只是具有自定义蓝色的系统字体的集合)。 我也尝试过手动设置文本附件的边界,或在文本前留一个空格,但似乎没有任何效果。
我究竟做错了什么?
显然是由于实现了TTTAttributedLabel
。 图书馆好像坏了。 从中切换后,附件开始正确显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.