I am trying to use NSMutableAttributedString with dotted underline below is my code but none of the Patterns seem to work am I missing something ?
var str : NSMutableAttributedString = NSMutableAttributedString(string: "HelloWorld")
str.addAttribute(NSUnderlineStyleAttributeName , value: NSNumber(integer:(NSUnderlineStyle.PatternDot).rawValue), range: NSMakeRange(0, str.length))
You have to do it like this:
Xcode 10 • Swift 4.2 or later
yourLabel.attributedText = NSAttributedString(string: "Hello World !!!", attributes: [.underlineStyle: NSUnderlineStyle.patternDot.union(.single).rawValue])
Note: for older Swift syntax check edit history
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With