Search code examples
iosswiftuilabelattributed

How to Create Label Doted Underline in Swift


I Want to doted underline on label in Swift

enter image description here


Solution

  • //you can add doted underline string like this in swift 5

    let string = NSMutableAttributedString(string: "Hello string")
                          string.addAttributes([.underlineStyle : NSUnderlineStyle.single.union(.patternDot).rawValue],
                                        range: NSRange(location: 0, length: string.length))
                       
    yourLableName.attributedText = string