I am new to iOS Dev and Xcode.
I was trying to practice Auto Layouts in Xcode.
So I was faced with a problem where I wanted to have my score label 20 points from the left side of stack view. So I embedded my label in a UIview element and was able to constraint it to 20 points from left. However, it seems like my UIview element's size has been locked and I am unable to reduce its size.
I want my view element to take same height as my score label which is like 71.5 points but it turns out that minimum height that can be reached for this UIview element is 333.5 as you can see in the image above.
So, how can I reduce its height and did I do anything wrong?
----------- Updated: Here are the constraints -----------
You can delete the MyView.top = top
constraint.
Your "Score:" label already has top
, leading
and trailing
constraints to MyView
, so add a bottom = Score:.bottom
constraint. That will tell the bottom of the white MyView
to stick to the bottom of the label.
You may also need to set the Score label's Content Hugging
vertical priority to Required (1000)
.
That should do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.