我通过以下方式在 NSAttributedString 中使用图标:
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.image = [UIImage imageNamed:@"notes-18w_18h.png"];
NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
[headerAS replaceCharactersInRange:NSMakeRange([headerAS length], 0) withString:@" "];
[headerAS replaceCharactersInRange:NSMakeRange([headerAS length], 0) withAttributedString:attrStringWithImage];
看起来它们有些像素化,但我不能 100% 确定,因为这是我第一次通过 NSAttributedString 使用图标。它看起来像这样:
原始图标如下所示:
这看起来好吗?或者我应该对我的图标做些什么来提高分辨率?