How to display the keyboard with a view above?


When a user taps on a button, I'd like the keyboard to pop up (which is easy), but I want a view that goes up along with it (sticking to the top of the keyboard). This view will be have a "send a message.." textfield. When the user pushes done, I want the keyboard to go away along with the view.

How do I make this view "stick" to the keyboard?

UITextFields have a property called inputAccessoryView

- Apple Documentation

- Relevant Stack Overflow Answer

This will pin whatever view you assign as that textfield's inputAccessoryView to the top of the keyboard.

Something important from the answer in that link to remember:

Note that the view you use should neither be in the view hierarchy elsewhere, nor should you add it to some superview, this is done for you.