Sto cercando di aggiungere una sottolineatura ad un testo nella mia app Swift. Questo è il codice che ho attualmente:Aggiungi NSUnderlineStyle.PatternDash a NSAttributoString in Swift?
let text = NSMutableAttributedString(string: self.currentHome.name)
let attrs = [NSUnderlineStyleAttributeName:NSUnderlineStyle.PatternDash]
text.addAttributes(attrs, range: NSMakeRange(0, text.length))
homeLabel.attributedText = text
Ma ottengo questo errore sulla linea text.addAttributes
:
NSString
non è identico aNSObject
Come posso aggiungere un attributo contenuta in un enum a NSMutableAttributedString in Swift?
puoi aggiornare il codice con la sintassi swift4. – Vats
@Vats, aggiornato. Guarda. – vacawama