Travis M.
Travis M.

Reputation: 11257

Autolayout: Reset Bottom Constrain After Toolbar is Hidden

I have a tableview that has it's bottom constrain set to the top of a toolbar, however, I sometimes hide this toolbar when the buttons are unnecessary.

How do I set up my tableview's bottom constraint to now be the bottom of the screen sans toolbar?

Do I set 2 bottom constraints in storyboard? Do I swap these out programmatically?

Upvotes: 1

Views: 271

Answers (1)

sha
sha

Reputation: 17860

Hiding view does't remove it from the layout calculations. You must do one of the following:

  • Have a constraint to align toolbar bottom to the bottom of the screen
  • Have a constraint to hold toolbar height
  • Reset that second constraint to 0 when you're hiding toolbar

or

  • Change the value for the constraint that align bottom of your tableView with top of the toolbar by adding/removing value equal to toolbar height

Upvotes: 2

Related Questions