cocoa - AutoLayout SubViews alignment to superview's center X -


enter image description here

how subviews alignment superview's center x?

i have 2 subviews added resizing able superview. subviewa want trailing alignment superview's center x , subviewb want leading superview's center x.

as situation how can do?

thanks

you can try add constraints following patterns (nslayoutconstraint class reference):

[superview addconstraint:[nslayoutconstraint constraintwithitem:subviewa                 attribute:nslayoutattributetrailing                 relatedby:nslayoutrelationequal                    toitem:superview                 attribute:nslayoutattributecenterx                multiplier:1.0                  constant:0.0]];  [superview addconstraint:[nslayoutconstraint constraintwithitem:subviewb                 attribute:nslayoutattributeleading                 relatedby:nslayoutrelationequal                    toitem:superview                 attribute:nslayoutattributecenterx                multiplier:1.0                  constant:0.0]]; 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -