In the docs about the visual format language for NSLayoutConstraint
there is an example where you specify button1 is equal in width to button2:
[button1(==button2)]
my question: is there a way to make button1 equal to button 2's with + a constant.. I tried:
[button1(==button2+10)]
and
[button1(==(button2+10))]
and both failed.. here is an error example:
A predicate on a view's thickness must end with ')' and the view must end with ']'
V:[tagWrapper(==tagButton+10)]
^'
(I obviously know you can do this by doing an NSStringWithFormat and simply filling in the variable in question.. but that looks too messy)
ideas?
P.S. just in case you're curious why I would like to stick with visual format language (as opposed to the other ways of doing it like this answer.. or using wrapper libraries out there.. check out this code sample)
Some constraints can't be specified with the visual format language. You could use a simple constraint like this:
NSLayoutConstraint *c;
c = [NSLayoutConstraint constraintWithItem:button1
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:button2
attribute:NSLayoutAttributeWidth
multiplier:1.0
constant:10.0];
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