title: Change UILabel attributed String color multiple times
body: <p>I am new to Swift 5 and am doing my first project.</p>
  
  <p>I want to change the color of some texts inside my label, this is what my label looks like:</p>
  
  <p>"You need to pay attention to <code>blue</code> texts, and even more to <code>red</code> texts. Try again so there is no more <code>blue</code> / <code>red</code> texts"</p>
  
  <p>I want to change all the "blue" to blue, and all the "red" to red. Did some research and this is what I found:</p>
  
  <pre><code>extension NSMutableAttributedString {
  
      func setColor(color: UIColor, forText stringValue: String) {
         let range: NSRange = self.mutableString.range(of: stringValue, options: .caseInsensitive)
          self.addAttribute(NSAttributedString.Key.foregroundColor, value: color, range: range)
      }
  
  }
  
  let mainString = popUpLabel.text!
  let blueString = "màu xanh" //(which is blue)
  let redString = "màu đỏ" //(whish is red)
  let attributedString = NSMutableAttributedString.init(string: mainString)
  attributedString.setColor(color: UIColor(red: 0.24, green: 0.65, blue: 0.96, alpha: 1.00), forText: blueString)
  attributedString.setColor(color: UIColor(red: 0.99, green: 0.20, blue: 0.20, alpha: 1.00), forText: redString)
  popUpLabel.attributedText = attributedString
  </code></pre>
  
  <p>And also tried this:</p>
  
  <pre><code>let mainString = popUpLabel.text!
  let blueString = "màu xanh" //(which is blue)
  let redString = "màu đỏ" //(which is red)
  let attributedString = NSMutableAttributedString.init(string: mainString)
  let blueRange = (mainString as NSString).range(of: blueString)
  let redRange = (mainString as NSString).range(of: redString)
  attributedString.addAttributes([NSAttributedString.Key.foregroundColor : UIColor(red: 0.24, green: 0.65, blue: 0.96, alpha: 1.00)], range: blueRange)
  attributedString.addAttributes([NSAttributedString.Key.foregroundColor : UIColor(red: 0.99, green: 0.20, blue: 0.20, alpha: 1.00)], range: redRange)
  popUpLabel.attributedText = attributedString
  </code></pre>
  
  <p>Both works pretty well for the first blue and red, but the second blue and red stayed in black and I don't know why.</p>