新的大标题功能可以通过largeTitleTextAttributes
它(与任何其他属性一样)带键进行自定义。这些键之一是/ 。dictionary
NSAttributedStringKey
NSAttachmentAttributeName
attachment
考虑一下:
let attachment = NSTextAttachment()
attachment.image = UIImage(named: "foo")
attachment.bounds = CGRect(x: 0.0, y: 0.0, width: 20.0, height: 20.0)
var largeTitleTextAttributes: [NSAttributedStringKey: Any] = [:]
largeTitleTextAttributes[.attachment] = attachment
navigationBar.largeTitleTextAttributes = largeTitleTextAttributes
问题是我分配给
largeTitleTextAttributes
属性的附件attachment
不可见。
如何将附件添加到属性字典中以使附件可见? (我不是在寻找NSAttributedString
's init(attachment: NSTextAttachment
)