Spail
Spail

Reputation: 703

Xcode 6 set default values for layout margins or disable them

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)?

Upvotes: 11

Views: 5690

Answers (2)

Marchy
Marchy

Reputation: 3734

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

Upvotes: 2

Rog
Rog

Reputation: 17170

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.

Upvotes: 3

Related Questions