2

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.

evenwerk
  • 947
  • 1
  • 12
  • 28

1 Answers1

1

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()
ArtFeel
  • 11,701
  • 4
  • 29
  • 41
evenwerk
  • 947
  • 1
  • 12
  • 28