0

enter image description here

I am having problem making my UILabel to react to my UITextView by changing its textColor.

So when there over 250 words in my UITextView, my UILabel will should turn red. But it for some reason doesn't do it.

// class NewAppViewController: UIViewController, UITextViewDelegate...
    func textViewDidChange(_ textView: UITextView) {
            let characterCounts = commentTextField.text.characters.count
            wordCountLabel.text = String(250 - characterCounts)
            if (250 - characterCounts) < 0 {
                self.wordCountLabel.textColor = UIColor.red
                sendButton.isEnabled = false
            } else {
                sendButton.isEnabled = true
            }
     }
Giraffe
  • 149
  • 1
  • 8

1 Answers1

0

I was being careless. I used UITextField by mistake. So now when I change back to UITextView, everything works fine.

Here is a picture.

enter image description here

Giraffe
  • 149
  • 1
  • 8