ios - Auto Layout defining constraints -


i have 2 buttons on uiview. want horizontal distance between these 2 buttons should, 20% width of superview?

any this?

you can accomplish using empty dummy view in between 2 buttons, width 20 % of width of superview.

in code, this:

// important thing here buttons flush against spacer [superview addconstraints:  [nslayoutconstraint   constraintswithvisualformat:@"[button1]-0-[spacer]-0-[button2]"   options:0   metrics:nil   views:@{@"button1" : button1, @"button2" : button2, @"spacer" : spacer}]]; // here, set width of spacer 20% of super view [superview addconstraint:  [nslayoutconstraint   constraintwithitem:spacer   attribute:nslayoutattributewidth   relatedby:nslayoutrelationequal   toitem:superview   attribute:nslayoutattributewidth   multiplier:0.2   constant:0]]; 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -