Check textView text is underlined in iOS swift
Solution:
The below function is used to check the textfiled,textView and label text has a property of underline.
func isUnderlined(attrText: NSAttributedString) -> Bool {
var contains: ObjCBool = false
attrText.enumerateAttributes(in: NSRange(location: 0, length: attrText.length), options: []) { (dict, range, value) in
if dict.keys.contains(.underlineStyle) {
contains = true
}
}
return contains.boolValue
}
Usage
if isUnderlined(attrText: mytextField.attributedText) {
}
Comments
Post a Comment