Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

constrain view.bottom to superview.bottom not bottomLayoutGuide in storyboard

In interface builder it only gives me the option of constraining my sub view to the bottom layout guide, not the superview. Because I am sometimes using the controller as a child controller in a container controller setup, I really want to constraint to the superview bottom, not the bottom layout guide.

enter image description here

like image 715
nwales Avatar asked Mar 12 '15 22:03

nwales


People also ask

How do you add top and bottom layout in storyboard?

Select your view. Select 'Add New Constraints' option in the InterfaceBuilder. From the dropdown menu of top or bottom constraint, select the 'Top Layout Guide' or 'Bottom Layout Guide'.

How do you add a constraint in Xib?

To create a constraint between two views, Control-click one of the views and drag to the other. When you release the mouse, Interface Builder displays a HUD menu with a list of possible constraints.

What is constraint to margin?

By unchecking "constraints to margin", you are adding constraints, meaning your interface will react correctly to changes in size or orientation.


2 Answers

As @Trianna Brannon pointed out, the approach in the other answer no longer works in Xcode7. In Xcode7 you have to right click your element, draw a line to the bottom until the constraint selector pops up.

Constraint selector

Then press ALT and now you'll get the desired Bottom constraint:

enter image description here

like image 137
Johannes Rudolph Avatar answered Sep 19 '22 13:09

Johannes Rudolph


Select your TableView and go to Editor -> Pin.
From there you have 4 options to pin to superview:

  • Leading Space to Superview
  • Trailing Space to Superview
  • Top Space to Superview
  • Bottom Space to Superview

enter image description here

This works as expected. The only downside is that you have to perform the pinning manually, as there are no shortcuts available.

like image 29
Fengson Avatar answered Sep 18 '22 13:09

Fengson