4thSpace 4thSpace - 2 months ago 12
iOS Question

How to consume entire View with Stackview

I have a this hierarchy:

View > Stackview > Tableview

The Stackview has these constraints:

- Trailing Space to: Superview

- Leading Space to: Superview

The Tableview has these constraints to the Stackview:

- Trailing Space to: Superview

- Leading Space to: Superview

The underlying class is a UIViewController. I get a tableview that looks like this:

enter image description here

Notice all of the right/left margin. Is there a way to get rid of the margins?

Answer

By default, Interface Builder constrains your views to margins, not the actual view bounds. Select your constraints (one by one), and go to the inspector view on the right, where you can control how the constraint is set up (like trailing <- > leading, bottom <-> top etc). Here, unselect Relative to margin.

XCODE IB MARGINS