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
  • 6,055
  • 2
  • 26
  • 29

4 Answers4

4

Set no of lines to 0

  lbl.numberOfLines = 0
Sudhanshu.B
  • 626
  • 9
  • 22
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
  • 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

enter image description here

Hope this will help you

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