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 89 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,243
- 11
- 24
Rahul Kumar
- 2,830
- 2
- 13
- 21
0
set label.numberOfLines = 0
If inside UITableView
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
Rahul Dasgupta
- 894
- 5
- 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
- 1,962
- 3
- 18
- 27