This new feature of Xcode 6 is kinda annoying. Most of the time I don't need to set offset relative to margins, and if I do I may want to use values other than default 16. Is there a way to change default value or totally disable margins for my project (or for all projects in my Xcode)?
Basically if the layout margins are 8,8,8,8 (the default), a constraint with 0 leading space to container margin will have an x position of 8. Note that this is only available on iOS8 or later.
By unchecking "constraints to margin", you are adding constraints, meaning your interface will react correctly to changes in size or orientation.
Layout margins provide a visual buffer between a view's content and any content outside of the view's bounds. The layout margins consist of inset values for each edge (top, bottom, leading, and trailing) of the view.
You cannot "turn them off" because they're built into UIView. You can set them to be zero:
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.layoutMargins = UIEdgeInsetsMake(0, 0, 0,0);
But you'd have to do it manually for every view. You could automate this for your own subviews by setting them after init and then overriding the setter with a version that throws any values passed in away. However... In general, its best to go with the flow and not fight the frameworks so I'd really suggest not trying to switch them off or ignore them.
Simply hold Option key (⌥) in the constraints pop-up to toggle between constraining to edge VS margin of views. Simple!
See full answer here: http://blog.manbolo.com/2014/10/09/xcode-6-auto-layout-margin-annoyances
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