AutoLayoutShorthand icon indicating copy to clipboard operation
AutoLayoutShorthand copied to clipboard

Assume superview for location constraints set to a constant

Open JoeSzymanski opened this issue 12 years ago • 0 comments

Per a previous pull request that had some errors, it would be nice to be able to have constraints with just one attribute assume that the second attribute is the superview (where necessary). This simplifies some common cases, like setting the top/left/bottom/right edges to be offset from the parent by some padding value.

Old way:

[view als_addConstraints:@{@"left ==" : @{als_view : als_superview, als_constant : @(10)},
                                         @"right ==" : @{als_view : als_superview, als_constant : @(-10)}}];

New way:

[view als_addConstraints:@{@"left ==" : @(10), @"right ==" : @(-10)}];

This time without build failures (testing compilation in a couple of projects to be sure).

JoeSzymanski avatar Apr 07 '14 12:04 JoeSzymanski