iOS - UIView above UITabBar with Layout Guide

833 Views Asked by At

I have a UIView above my UITabBar that will be able to show and disappear. The View is added as a SubView in the UITabBarController's View. I want to change the Bottom Layout Guide depending on the View's state.

Example: When the View is hidden, the Bottom Layout Guide is animated to the TabBarController's default. When the View is visible, the Bottom Layout Guide animates to the TabBar's height + the height of the View above the TabBar.

How can I achieve that?

An example of what I am making.

1

There are 1 best solutions below

4
On BEST ANSWER

The result I wanted can be achieved in iOS 11 by using the additionalSafeAreaInsets on the desired ViewController.

viewController.additionalSafeAreaInsets = UIEdgeInsetsMake(0, 0, offsetFromBottom, 0)

If you want to animate the elements adapting to the updated insets add this code along with the updated insets to your animation block.

viewController.view.layoutIfNeeded()