ios - Get same result with NSLayoutConstraint as with Autosizing -
in ui have 5 buttons @ bottom. autosizing applied every button on picutre:
i desired results:
however, when tried autolayout in ib or in code this:
nsdictionary *viewsdictionary = nsdictionaryofvariablebindings(_button1, _button2, _button3, _button4, _button5); nsarray *constraints = [nslayoutconstraint constraintswithvisualformat:@"|-[_button1]-[_button2]-[_button3]-[_button4]-[_button5]-|" options:nslayoutformatalignallbaseline metrics:nil views:viewsdictionary]; [self.view addconstraints:constraints];
i this:
even when try set default width, don't behaviour expected.
you need set equal width
constraint buttons , set horizontal space
constraint between each buttons through ib.
to set equal height
* select buttons
* editor -> pin -> width equally
hope works well, worked me.
Comments
Post a Comment