Reputation: 94
I have been trying to achieve following layout in autolayout I want to acheive this
may be i am doing something wrong due to which i am getting following result.I get this
can anyone correct me ?
Upvotes: 1
Views: 84
Reputation: 148
As said above, use your element inside a horizontal stackview. Unfortunately, if you’ve a iOS target iOS 9.0, you will have to use another trick. Your stackview will become a normal view which will contain your elements to align. After that, you can the element width to be equal to their superview with the multiplier use.
Per example if you have 3 elements inside your view but you want that the first one being larger than the two others by setting the multiplier with a certain ratio like 2:4 for the first one and 1:4 for the last ones :-)
Upvotes: 0
Reputation: 1373
This kind of layout is easily accomplished by using UIStackView, Please use UIStackView either in storyboard or in code.
Please check Apple documentation on it https://developer.apple.com/documentation/uikit/uistackview?changes=_6
Upvotes: 2
Reputation: 2092
If you are using storyboard for Textfield then simply give leading and trailing to Textfield. Dont give the fixed width to textfield, it will work for all devices. Same logic if you are setting textfield programatically. Dont give fixed width
Upvotes: 0