1

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.

Devran Cosmo Uenal
  • 5,813
  • 2
  • 23
  • 29

4 Answers4

4

Set no of lines to 0

  lbl.numberOfLines = 0
S. Bharti
  • 616
  • 9
  • 21
2

After providing proper constraint, set no of lines 0 in storyboard as given below in image-

enter image description here

And Set Constraints leading , training , top and bottom .

Dixit Akabari
  • 1,959
  • 9
  • 21
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
}
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

enter image description here

Hope this will help you

Ganesh Manickam
  • 1,782
  • 3
  • 17
  • 26