-2

I want to make my app compatible with iPhone X. I'm not using storyboard or xibs, just code. When I run my app on the simulator the view overlaps part of the status bar and the home bar at the bottom. Is there a way to programmatically adjust the view so that it fits within the bounds? Any help is appreciated.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ali Feili
  • 61
  • 1
  • 9

1 Answers1

0

I believe the answer you are looking for is called safeAreaInsets, which are basically insets that considers the position of the iphoneX exclusive UI components such as the navigation bar and the home bar.

You should adjust the sizes and constraints of your UI components according to the safe area as opposed to the screen, for and non iphoneX devices, it would be 0, which means it would be the same as adjusting according the the screen sizes instead.

The docs for it is at: https://developer.apple.com/documentation/uikit/uiview/positioning_content_relative_to_the_safe_area

Tonton
  • 68
  • 1
  • 7