I'm trying to make an application that includes a replica of the Japanese iOS keyboard.
I managed to recreate it in interface builder. I've embedded the keys in their own view, and autolayout for the keys works perfectly.
My issue is that I want the keyboard to match the system one exactly. The keyboard view should appear 4 pixels from the bottom on iPhone models with bezels and 80 pixels from the bottom for the X-series of iPhones to account for their lack of bezels.
I don't really want to hardcode the constraints based on the iPhone model. What is the best way to position the keyboard to account for both kinds of phones?
Is there a way to detect if an iPhone has bezels?
The only difference is:
iPhone X series:
bottom = KeyboardView.bottom + 80
Others: bottom = KeyboardView.bottom + 4
You should be using a UIInputViewController and its inputView
. The "keyboard" (the input view) will automatically appear in the right place on all device types.