iOS Underline Text: How to Use NSAttributedString for Underlining
The property "underlineThickness" is not a valid property in iOS. However, you can achieve underlining text in iOS by using the "NSAttributedString" class and setting the "NSUnderlineStyleAttributeName" attribute to specify the underline style. Here is an example:
let attributedString = NSMutableAttributedString(string: \"Underlined Text\")
attributedString.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.single.rawValue, range: NSRange(location: 0, length: attributedString.length))
// Apply the attributed string to a label or text view
label.attributedText = attributedString
This will create an attribute string with underlined text and apply it to a label or text view. You can adjust the NSUnderlineStyle value to customize the underline style.
原文地址: https://www.cveoy.top/t/topic/pKfw 著作权归作者所有。请勿转载和采集!