title: Hiding a UIButton when a text field is clicked on Swift
body: <p>New to Swift and making a simple to-do app. </p>
  
  <p>I am trying to get it so that when a UI TextField is clicked on, a certain button should be hidden. It's only when the user presses enter after typing in a task that the button should appear.</p>
  
  <p>I have an IBAction set up for my text field to hide the UIButton when it is clicked on like so, but it doesn't work:</p>
  
  <pre><code>  @IBAction func textFieldClicked(_ sender: Any) {
  
          self.cellButton.isHidden = true
  
  }
  </code></pre>
  
  <p>And I have set up my textfieldshouldreturn function when the user presses enter like so:</p>
  
  <pre><code>func textFieldShouldReturn(_ textField: UITextField) -&gt; Bool {
  
      self.cellButton.isHidden = false
      self.cellButton.isUserInteractionEnabled = true
      textField.resignFirstResponder()
      return true
  }
  </code></pre>
  
  <p>Does an IBAction for text field only respond when enter is pressed? I tried messing with flags but that didn't work either.</p>
  
  <p>Any help is appreciated.</p>