2

Hoping someone can help me with the height below the Tabbar in Iphone X. I need to remove this height in one of my frame sizes for IPhone X. The new status bar has a different height and I can reference that height with:

UIApplication.shared.statusBarFrame.height

Does anyone know how I can reference the height below the Tabbar in Iphone X?:

enter image description here

ajayb
  • 633
  • 1
  • 9
  • 23
  • 3
    possibly duplicate https://stackoverflow.com/questions/46239960/extra-bottom-space-padding-on-iphone-x –  Sep 25 '17 at 21:03

3 Answers3

4

I think this is what you are looking for:

if #available(iOS 11.0, *) {
  print(view.safeAreaInsets.bottom)
}

This is because of the new safe area introduced in iOS 11, and will give the space you are looking for on the iPhone X. It will vary by device however.

Pranav Kasetti
  • 8,770
  • 2
  • 50
  • 71
2

I don't know why you want this indicator to be hide. But as per Apple recommended guidelines, it's mentioned to not cover this space/area with other views.

Don't mask or call special attention to key display features. Don't attempt to hide the device's rounded corners, sensor housing, or indicator for accessing the Home screen by placing black bars at the top and bottom of the screen. Don't use visual adornments like brackets, bezels, shapes, or instructional text to call special attention to these areas either.

Link - Interface guidelines for iPhone-X

But, if your requirement is to play Video in a Landscape mode.
You can auto-hide a indicator while playing. It will reappear automatically when user will touch the screen while video play.

For auto-hide, You can override prefersHomeIndicatorAutoHidden in respective ViewController.

override func prefersHomeIndicatorAutoHidden() -> Bool {
        return true
    }
Kiran Jasvanee
  • 6,362
  • 1
  • 36
  • 52
0

To calculate the free space between the nav bar and the tab bar you can convert their coordinates to your VC's view's space and then just subtract.

I find this easier than trying to add together all the possible things that will affect the safe are. Plus it has the benefit of being compatible with iOS versions before the SafeAreaInset was introduced.

CGRect navBarFrame = [self.view convertRect:self.navigationController.navigationBar.bounds fromView:self.navigationController.navigationBar];
CGRect tabBarFrame = [self.view convertRect:self.tabBarController.tabBar.bounds fromView:self.tabBarController.tabBar];

return CGRectGetMinY(tabBarFrame) - CGRectGetMaxY(navBarFrame);
pat
  • 63
  • 1
  • 5