Titouan de Bailleul Titouan de Bailleul - 3 months ago 27
iOS Question

Make UIScrollView fill parent view with constraints

I am simply trying to add a scrollview in the view in Interface Builder and use constraints to have this scroll view fill its superview entirely

This is basically how it looks

enter image description here

Why - when I click on the trailing or leading constraints - is the constant set to -20 instead of 0?

Why - when I run the app and inspect the view - can I see that the view has a width of 375 (running on iPhone 6) but the scrollview has a width of 383?

Answer

Uncheck Constraint to margins when you setting constraint to your scrollview. By default it is checked and it constraints from margin.

check the screenshot below,

enter image description here