title: Disable UIButton after UITextField is no longer hidden?
body: <p>I have a simple task but I don't seem to be able to figure it out. I have a <code>UIViewController</code> that has 5 <code>UITextFields</code>. 2 of those <code>UITextFields</code> are always visible. The other 3 are being shown when the user hits a <code>UIButton</code>.  My goal is to disable the <code>UIButton</code> so it's obvious to the user that they cannot "add" more <code>UITextFields</code> after ALL of the <code>UITextFields</code> are visible. I tried to do this: </p>
  
  <pre><code>@IBAction func addTextFieldPressed(_ sender: UIButton) {
      if !thirdChoiceTextField.isHidden, !forthChoiceTextField.isHidden, !fifthChoiceTextField.isHidden {
          addTextFieldButton.isEnabled = false
      }
          if thirdChoiceTextField.isHidden {
              UIView.animate(withDuration: 0.2) {
                  self.thirdChoiceTextField.isHidden = false
              }
          }
          else if forthChoiceTextField.isHidden {
              UIView.animate(withDuration: 0.2) {
                  self.forthChoiceTextField.isHidden = false
              }
          }
          else {
              UIView.animate(withDuration: 0.2) {
                  self.fifthChoiceTextField.isHidden = false
  
          }
      }
  }
  </code></pre>
  
  <p>But it doesn't work. You're able to add the <code>UITextFields</code>. There's also a <code>UIButton</code> that allows the user to remove the 3 added <code>UITextField</code>. So, I have to make sure that if all of the text fields are shown, the <code>UIButton</code> responsible for adding more <code>UITextFields</code> would be disabled, but if any of the <code>UITextFields</code> is removed (<code>.isHidden = true</code>), the button should be enabled once again.</p>
  
  <p><strong>UPDATE:</strong> This is the code that runs after the user hits the "hide" button and it basically hides either 3rd, 4th or 5th <code>UITextField</code></p>
  
  <pre><code>@objc func hideTextField(_ sender: UIButton) {
      if let  field = sender.superview?.superview as? UITextField, !field.isHidden {
          UIView.animate(withDuration: 0.2) {
              field.text = ""
              field.isHidden = true
          }
      }
  }
  </code></pre>