1
votes

When I set a constraints on vertical buttons, the height of vertical buttons are dynamically changed according to screen size. What am I doing wrong ?

constraint are satisfy for adaptive layout

Preview for different iphone screen

Constraints for top blue button is :

Trailing space to : superview is : 10

Top space to : top layout is : 146

bottom space to : green button is : 45

equal width to : green,brown,dark pink

equal height to : green button,brown button, pink button

Green button constraints are :-

trailing space to : superview : 10

leading space to : pink button is : 35

algin center Y to : Dark Pink

Bottom space to : brown button is : 53

top space to : blue button is : 45

equal width to : blue button

equal height to : blue button

Brown button constraints are :-

Trailing space to : superview is : 10

bottom space to : bottom layout is : 56

top space to : green button is : 53

equal width to : blue button

equal height to : blue button

pink button constraints are :-

leading space to superview is : 5.0

trailing space to : green button is : 35

align center Y to : Green button

equal width to : blue button

equal height to : blue button

1
What constraints have you set? What do you expect to see - Paulw11
I want to see exactly same as storyboard.. but when i set constraints for all buttons its show me rectangle instead square button in iphone 3.5 inch - Vikash Sharma
If you want square. Tutors then one of your button should have an aspect ratio constraint of 1:1 from its width to its height - Paulw11
constraints which i set for all buttons are correct ? - Vikash Sharma
None of them are necessarily incorrect (although large negative values look strange) but you do not have any constraints that requires the height to be the same as the width. In fact you don't have any height constraints, so it will use the default button height which is defined by font size plus padding. - Paulw11

1 Answers

0
votes

The constraint you need to set for each button is "height" and "width"