iOS 8 after hiding tab bar - reuse this space to display a text box

1k Views Asked by At

I can hide the tab bar programmatically. The view underneath is a scrollview displaying content. When I scroll up/down I can see the white space at the bottom where the tab bar used to be. My content is not able to use that space.

I want to display a text box in that white space along with some buttons. Any suggestions on how can I do that?

Solution: Thanks to "SwiftArchitect" advice. I was able to fix this by adding bottom constraints for the ScrollView. Now the scrollview goes till the bottom of the screen.

1

There are 1 best solutions below

1
On BEST ANSWER

As often is the case with AutoLayout, this question becomes trivial when using Storyboard and either the ViewLayoutAssistant or an image which will show evidence of resizing.

Let's assume that you are adding 4 constraints for your scroll view:

  1. vertical space view.top (0) equal to Top Layout Guide.bottom
  2. vertical space view.bottom (0) equal to Bottom Layout Guide.top
  3. and 4. horizontal leading and trailing space

...then when hiding the tabBar:

if let tabBarController = self.tabBarController {
    tabBarController.tabBar.hidden = true
}

the view.bottom, anchored to the Bottom Layout Guide.top, will now stretch all the way to the bottom. If you add a UILabel above that line, it will show.

Here is what it would look like in the Storyboard:

A storyboard with a navBar and 2 UIViewControllers

When executed with the ViewLayoutAssistant, the UIViewController that hides the navBar as follow will look like this (notice that the view now stretches all the way to the bottom since the Bottom.Layout.Guide moved down):

enter image description here