Search code examples
autolayoutnavigationbariphone-x

UIView used to create custom navigation bar at top leaves space at top in iphone x


enter image description hereI have used one uiview to create custom navigation bar in my application.I have given leading and trailing constraints zero and heigh 84,and top space to superview = 20.This looks fine in other devices but in iphone x it leaves space at top.Please see attached screenshot. How to resolve this?enter image description here

enter image description here


Solution

  • Made changes in custom navigation bar using this article: https://medium.com/@kahseng.lee123/creating-custom-navigation-bar-tab-bar-for-iphone-x-f03b1e1827d3

    I have added one extra background view and given it leading,trailing and top constraint zero with respect to its super view and align bottom to custom navigation view.And for navigation view changed height constraint to 44 and leading trailing and top constraint to zero with respect to safe area. And this solved the problem.