HTML Format in UITextView

前端 未结 8 1097
轻奢々
轻奢々 2020-12-01 07:19

i\'m quite new to iOS Development and right now working on an app which receive some kind of JSON Data. But some Backend Experts thought, that it would be better for the Use

8条回答
  •  醉梦人生
    2020-12-01 07:26

    I used code for Swift 4:

    var descriptionStr : String = String() //Dynamic text
    
    let regex = try! NSRegularExpression(pattern: "<.*?>", options: [.caseInsensitive])
            let range = NSRange(location: 0, length: descriptionStr.count)
            let htmlLessString: String = regex.stringByReplacingMatches(in: descriptionStr, options: NSRegularExpression.MatchingOptions(), range:range, withTemplate: "")
            textViewRef.text = htmlLessString
    

提交回复
热议问题