O uso de NSMutableParagraphStyle causa problemas com emojis
No meu aplicativo, quero alterar a altura da linha, estou usando esta extensão de string:
extension String {
func addLineHeightWith(alignement: NSTextAlignment) -> NSAttributedString {
let attrString = NSMutableAttributedString(string: self)
let style = NSMutableParagraphStyle()
style.lineSpacing = 5
style.minimumLineHeight = 5
style.alignment = alignement
attrString.addAttribute(NSAttributedStringKey.paragraphStyle, value: style, range: NSRange(location: 0, length: self.count))
return attrString
}
}
Estou tentando aplicá-lo em um UILabel:
let str = "Hi%5E%5E%F0%9F%98%AC%F0%9F%98%AC%F0%9F%98%AC%F0%9F%98%AC%F0%9F%98%AC%F0%9F%98%AC%F0%9F%98%AC"
if let decoded = str.removingPercentEncoding {
print(decoded)
label.attributedText = decoded.addLineHeightWith(alignement: .center)
}
Aqui está o resultado no console:
E o resultado na tela:
Qualquer ideia? Obrigado