title: Make half of the TextView's text color Different than other 50% of the text SWIFT
body: <p>I've got a large text in my UITextView and I want to make the 50% of the text's color red and the other 50% green . I've added NSMutableAttributedString in the TextView but it works's for the full range of the text . How to divide the textView's text into two sections and color them into red and green ?</p>
  
  <pre><code>let strNumber: NSString = self.text as NSString // TextView Text
          let range = (strNumber).range(of: strNumber as String)
          let attribute = NSMutableAttributedString.init(string: strNumber as String)
          attribute.addAttributes([NSAttributedString.Key.font : UIFont.systemFont(ofSize: 14) , NSAttributedString.Key.foregroundColor : UIColor.red], range: range)
          self.attributedText = attribute
  </code></pre>