InputAccessoryView and iPhone X

Rohit Pal
Code w/ rohit
Published in
3 min readNov 18, 2017
safe area in iPhone X

With recent release of the iPhone X this year with loads of features, Apple removed the home button from this most awaited product and used bigger 5.8-inch display with rounded corners that follow a beautiful curved design. Instead of pressing home button to navigate to home screen, Apple provided a single gesture to bottom home screen indicator to perform the task.

inputAccessoryView in iPhone X

Your App should utilise the safe area and avoid explicitly placing interactive controls at the very bottom of the screen and in the corners. If you are following top and bottom layout guide then you don’t have to worry about as SDK takes care of it.

If you’re using input accessory view in your app, you’ve to explicitly handle the bottom anchor of it. Otherwise your input accessory view will look like as in the image .

You can fix it by activating bottom anchor to safe area.

  1. Open inputAccessoryView xib file and check Use Safe Area Layout Guides option. In size inspector tab uncheck Safe Area Layout Guides.

2. Now click on contentView and check on Safe Area Layout Guides in size inspector.

Under size inspector menu of content view check Safe Area Layout Guide Option

3. Anchor elements to safe area bottom.

Add Bottom constraints to safe are bottom

4. Compile and run. You’ve fixed this problem.

Note: If you are still facing problem then make sure you call becomeFirstResponder()on or after viewDidAppear(_ animated: Bool).

Input accessory view after anchoring to safe area layout guide

Background colour of bottom area changes according to content view colour

You can find sample code at https://github.com/rohitpal440/InputAccessoryViewExample

Originally published at www.codewithrohit.com

--

--