How can I place two views in a single screen using autolayout Constraints

132 Views Asked by At

I would like to create apps which have 2 views (top & bottom).

The top view is scrollable and contains multiple textfields and labels.

The bottom view is non-scrollable but needs to auto adjust to fit into bottom screen like a keyboard when the screen size is changed (I want it to be usable from iPhone 4 to 6 Plus). The bottom view will contain a custom function button to trigger actions and updates in the top view.

I have this working on Android with LinearLayout, but I'm stuck with iOS.

Screenshot

2

There are 2 best solutions below

2
On BEST ANSWER

Try to place table view or scroll view in top which will scroll and a UIView on bottom. make the height of UIView constant and table view or scroll view which you will use in top will change the height according as the screen size. If you got confused the post the comment.

For table view see this tutorial iOS - Custom table cell not full width of UITableView

Step1 : Place table view and view as below . upper part is table view and lower is view

enter image description here

Step2: Place the constraints for view as below

AT first

enter image description here

At second

enter image description here

Step 3: Place the constraints for table view as below

enter image description here

Try and inform me what u got

1
On

In your case I will suggest to drag all those buttons into a UIView. Then place the buttons with the desired spacing. Select all the buttons and give equal width and equal height constraint. And then give spacing constraints between neighbour buttons or views. And then give constraint for the UIview to the UIViewcontroller