[Solved] Changing the view color when comparing values


In your view controller you need to add UITextFieldDelegate which will allow you to access methods related to your text field. The top of your view controller should look like this:

class ViewController: UIViewController,UITextFieldDelegate  //set delegate to class 

You then need to set the delegate of your text field to self in viewDidLoad and add a target for when the text field changes:

override func viewDidLoad() {
    super.viewDidLoad()
    localTemp.delegate = self     //set delegate to this vc
    localTemp.addTarget(self, action: "textFieldDidChange:", forControlEvents: UIControlEvents.EditingChanged)
}

You can then implement this method which will run on every key press and you need to call your changeColor() method as above:

func textFieldDidChange(textField: UITextField) {
    self.changeColor()
}

16

solved Changing the view color when comparing values