I want to set label height according to text. currently it is showing only one line text. I have set constraint leading training and top but its not working.
Asked
Active
Viewed 97 times
1
-
Is it inside uitableview – Rahul Dasgupta Dec 18 '17 at 07:14
-
where's your code? "it's showing only one line" vs. what are you expecting/wanting it to show? – SherylHohman Dec 18 '17 at 07:17
4 Answers
2
After providing proper constraint, set no of lines 0 in storyboard
as given below in image-
And Set Constraints leading , training , top and bottom .

Dixit Akabari
- 2,419
- 13
- 26

Rahul Kumar
- 3,009
- 2
- 16
- 22
0
set label.numberOfLines = 0
If inside UITableView
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}

Rahul Dasgupta
- 894
- 6
- 18
0
To get multiple lines of text based on content we can simply done via interface builder
1)set Lines to 0
2)Line break to wordwarp
For reference see below screenshot
Hope this will help you

Ganesh Manickam
- 2,113
- 3
- 20
- 28