The end of my NSAttributedString
with emojis in the contents is not being formatted. I'm trying to format the entire string (set the text color to white in this example, for simplification), but some of the text stays unformatted when put in a UILabel
.
Currently, I'm using
let attributedString = NSMutableAttributedString(string: contents)
attributedString.addAttribute(
NSForegroundColorAttributeName,
value: UIColor.white,
range: NSMakeRange(0, contents.characters.count)
)
label.attributedText = attributedString
I've also tried getting the length by using contents.utf8.count
but get the same result.
I noticed that the number of unformatted characters is the same as the number of emojis in the string. Could that have something to do with what's going on?