So the main problem is showing in the picture itself. How can I make a double line horizontally label using my constraints, so I could show the entire text without cutting it?
Asked
Active
Viewed 82 times
0
-
What are the constraints you have on your UILabel? – R P Feb 14 '16 at 20:54
2 Answers
1
You can achieve that with two changes,
- Set the
Lines
field in attribute inspector to0
- Do not specify a fixed height constraint for your UILabel.
Update:
In order to make the constraints to behave properly for a given UI element, you will have to have a minimum of 4 constraints on it.
- Constraint to define its X position
- Constraint to define its Y position
- Constraint to define the width of the element
- Constraint to define the height of the element
Since I do not have a clear picture of what your UI would look like, I'm giving a simple example. Assuming you have two labels one below the other and you want multi-line behavior for the second UILabel
.
- Define your X position, add a
leading edge
constraint to the margin or the edge based on your requirement - Define your Y position, add a
vertical spacing
constraint from your second label to the first label - To define the width, add a
trailing edge
constraint to the trailing margin or the edge - To define the height, add
height >= 20
(or the number you need) constraint
And ensure you have the lines
property to be 0
.

R P
- 1,173
- 2
- 11
- 20
-
Thank you RP, did the 1st step but couldn't understand well the 2nd one. Because I think I don't have any fixed height, or didn't understand what you meant. The label has 2 constraints as I can see, a Center Y alignment constraint and Horizontal space contraint. I think is related to the first one. Here is a pic about I have https://i.imgur.com/wAYmdZG.png – tomasfn Feb 14 '16 at 22:27
-
Check out this SO question to understand further: http://stackoverflow.com/questions/12789013/ios-multi-line-uilabel-in-auto-layout?rq=1 – R P Feb 15 '16 at 01:12
0
You can do with on storyboard. Click it later look at bottom side Resolve >Auto Layout Issues and click update frames. i think auto do this.
Thanks

SwiftDeveloper
- 7,244
- 14
- 56
- 85