0

I want to ensure that when the keyboard is not visible, the input is anchored to the upper part of the tabBar. When the keyboard is visible, I want it to be layered above the tabBar, and the input should be attached to the view's keyboardLayoutGuide.topAnchor.

The desired behavior can be seen in these screenshots: no input focused

extended keyboard

Here is the pseudocode:

func setupConstraints() {
   if (keyboard is visible) {
       input.view.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor).isActive = true
   } else {
       input.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true   
   }
}

How can I archive such a behavior or update the constraints in a Observer on keyboardWillHideNotification/ keyboardWillShowNotification?

Leo
  • 48
  • 5

0 Answers0