I'm trying to create a label with text, prepended with an icon, but unfortunately I'm unable to change the color of just the icon. It's always tinted with its default color.
This is how I do it:
var titleStringAttribute = NSMutableAttributedString(string: "")
var iconAttachment = NSTextAttachment(image: UIImage(systemName: "trash")!)
iconAttachment.image?.withTintColor(.red, renderingMode: .alwaysTemplate) // Does not work?!
titleStringAttribute.append(NSAttributedString(attachment: iconAttachment))
// Appending bold text to attributedText
theLabel.attributedText = titleStringAttribute
I also took a look into StackOverflow and other websites on the internet, but nothing helped yet.
I'm working with iOS 13.5.
Thanks for your answer!