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

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift