Reputation: 1597
i'm trying to develop a calculator using swift (see image)
since i have not entered any constraints, when i run the app on iphone screen larger than 4 inches, buttons remain in the same position (see image)
which constraints can i enter to ensure that the size of the buttons can grow with the increase of the screen size? Note that the red view is a content view inside a scroll view so with the following hierarchy:
where scroll view has the following constraints: (leading, trailing, bottom and top to his superview) while the content view has: (leading, trailing, bottom, top, equal width and equal height to scroll view)
EDIT: in response to Rizwan Shaikh
it works, the only problem is that the container view (red) has become lower than the scroll view (green) when i run the app with iphone 6/6 plus (see image), rather on the iPad the buttons exceeds the size of the container view forcing the scroll view to scroll vertically, why this happening?
EDIT 2: in response to Rizwan Shaikh
Thank you!
Upvotes: 1
Views: 3724
Reputation: 2904
you should used constraint like
firstButton LeadingSpace = 20 from mainView
secondButton LeadingSpace = 20 from firstButton
thirdButton LeadingSpace = 20 from secondButton
thirdButton TrailingSpace = 20 from mainView
also select all the button in the given row go to Editor -> Pin -> widths equality
it will make your all button of same widths
similarly specify the top and bottomSpace like this
firstButton TopSpace = 20 from mainView
fourthButton topSpace = 20 from firstButton // consider 3 button in one row
fourthButton BottomSpace = 20 from MainView
Upvotes: 2