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 81 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 .
![](../../users/profiles/7367823.webp)
Dixit Akabari
- 1,959
- 9
- 21
![](../../users/profiles/5251507.webp)
Rahul Kumar
- 2,061
- 1
- 11
- 18
0
set label.numberOfLines = 0
If inside UITableView
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
![](../../users/profiles/4625711.webp)
Rahul Dasgupta
- 857
- 5
- 17
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
![](../../users/profiles/6540962.webp)
Ganesh Manickam
- 1,782
- 3
- 17
- 26