Could someone help me understand the difference between "trailing space to container" and "bottom space to bottom layout" in interface builder auto layout?
I'd like to put a layout constraint in place that ties the bottom of a view to the bottom of it's superview. Both of the above sound like they should accomplish this.
Any clarification would be greatly appreciated.
Leading/trailing is horizontal spacing. (It's not labeled "left" and "right" because it swaps for right-to-left languages.) Top/bottom is exactly what it says.
"To Container" and "to Layout Guide" are defined differently, but work similarly in practice. "To Container" constraints control the space between a UI element and the edge of its superview (or other containing UI element). "To Layout Guide" constraints are a special case for vertical spacing -- since views extend underneath transparent navigation/status/tab bars in iOS 7, you generally want to control where a UI element appears relative to those instead of to the edge of the view.
So...
I'd like to put a layout constraint in place that ties the bottom of a view to the bottom of it's superview.
"Bottom Space to Bottom Layout Guide" is what you want for that. That'll set spacing relative to the bottom of the superview if there's no tab bar, and relative to the tab bar if one exists.
Don't forget to uncheck "Relative to margin"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With