Custom Uitoolbar Too Close to the Home Indicator on iPhone X

positioning UIBarButtonItem vertically (for iPhone X)

In the app for which I asked the question, I am positioning views on the screen using coordinates. (In a constraint based app, one would need to pin the bottom constraint of a bottom toolbar to the safe area rather than the superview; if you are using the built-in bottom toolbar belonging to the navigation controller, the position of the toolbar and its content will take care of itself). Surprisingly, the solution turned out to be simply lifting the bottom toolbar up using its y coordinate, no more than 34 pts, and the area below the toolbar and near the home indicator will simply assume the color of the bottom toolbar, making it appear as though that area is part of a taller-than-normal bottom toolbar. The buttons on the toolbar will no longer appear squished.

iPhone X custom tab bar issue

How about making a view effect view at the bottom, which is larger than 44pt? I have tried it in my application and it works well.

  • refer: https://novemberfive.co/blog/apple-september-event-iphonex-apps/

How to extend bottom view colour below the home indicator in iPhone X?

Krunal's answer works in most cases. But if you don't have that top constraint set, the white view will go under the home indicator line.

Sample Image

In my design, the white view had leading ,trailing,bottom and height constraints only. I had to add another view as a subview to the white view (This view will act as the white view from now),enable the safe area layout guide for the outer white view and set the constraints to the margin/safe area in order to get this thing work for all the devices including X.

NB: Height constraint should be set for the inner view/Button(in my case) and not for the outer view. Autolayout will properly do the work for you in iphone X device.

Sample Image

This is how it looks in iphone X and other phones.
iPhone SE:

Iphone 5c

iPhone X:

Sample Image

Hope this may help someone. :)

Last view added to content view of scrollview goes behind the home indicator

As of iOS 11 and new iPhone X devices and forward this is the default behavior of safeAreaLayoutGuide.

Scroll view subclasses like table view and collection view handles this problem automatically if you pin the bottom anchor to safe area.

Since you are populating a scroll view manually you need to get the bottom safe area height and inset the scroll view with that value.

You can do it like this:

scrollView.contentInset.bottom = view.safeAreaInsets.bottom


Related Topics



Leave a reply



Submit