Search code examples
swiftxcode10.3

Resizing subviews with AutoLayout


I'm setting constraints for a subview within a scroll view and the subview resizes to be ~100 wider than the superview, even when I set leading and trailing constraints

I've tried setting leading and trailing constraints

Image of my current constraints and the problem


Solution

  • Scrollview expects it's size from it's children not vice versa , you need to ctrl - drag from the recipes view to main outer view ( Home vc's view ) and select equal widths from the popup