XCode: How To Adjust Items In A UIStackView - ios

How do I adjust the TextField inside my StackView to fill in the gap between it and the label that I also have placed in there? I'm using the Storyboard.
Currently looks like this:
Desired look:
Thank you.

This is achievable by just using nested UIStackView.
Add a Horizontal UIStackView first with spacing as 15 and distribution and alignment as Fill.
Inside it add two vertical UIStackView with both set to fill equally as the distribution and alignment as Fill. The spacing can be set to 10.
Inside the first vertical one add two UILabel and inside the second one add two UITextField.
And this will result in:
The labels will expand to fit the largest label.

Related

Bigger Width for a specific item in UIStackview in Swift

There are 7 labels in 7 UIView and UIViews are inside StackView. I want just one view ( middle one) has more width than others because labels don't fit. Is there any way to do that?
When I change StackView from Fill Equally to Fill Proportionally.
I think you should set fill proportionally in distribution field.

how to use stackview for label and textfield together in which textfield has more length

I'm new to stackviews. I'm trying to build the following using stack views.
But when I apply horizontal stackview to the label and textfield together the textfield's length is not as I required. I tried all the allignment and distribution combinations of horizontal stack view. But there is no result. Please help me.
Thanks in advance.
First add a stackview with axis property to vertical, and alignment property to Fill like this
And then add a stackview with axis property to horozontal, and alignment property to Fill, and distribution also fill. Like this
You will get idea of how to set your view accordingly.

Two UILabels like UITableViewCellRightDetail using UIStackView

I have a Horizontal UIStackView with two UILabels. I need it to be styled like UITableViewCellRightDetail.
The first Label (on the left) should have more priority in resizing.
Here is the example:
I need it to be like this:
You can just use right alignement for the second label to achieve the desired appearance on your second image.
However this will not affect size of the labels. If you want first label to fit as much as it can, you can define a width constraint and set it manually from code after you calculate it. The second label will just have leading and trailing constraints.

Make spacing between stackviews

I'm new to stackviews and have been trying to use it in a collectionViewCell. This works kind off however i would like to make spacing between the label and image and the two labels. Beside this i also want to make spacing between the label and the edges of the collectionViews. How can i achieve this? here is some images of my stackviews
i would like to make spacing between the label and image and the two labels
Select the vertical stack view right beneath ItemCell, then go to the attributes inspector and change the spacing value, as shown below.
Beside this i also want to make spacing between the label and the edges of the collectionViews.
You have to use constraints to achieve this.

same space retain between three label using autolayot

I am learning auto layout from last two days, i have one UITableViewCell xib file and in this cell there is two Labels and one Button, How can i manage Horizontally and vertically space between this subviews of cell?
Thanks in advance.
This trick is to add empty placeholder UIViews between your labels/buttons and bind them with an Equal Width constraint.
Following images show how it is done for horizontal spacing. Purple colored views are the placeholder UIViews. You can later set their alpha=0 or make them hidden so they will not appear when the app is running.

Resources