0

I would like to have the bookSummary in a new line.

this is my current code, which sets a UILabel inside a UITableViewCell:

cell.detailTextLabel?.text = "\(books[indexPath.row].bookAuthor ?? "") - \(books[indexPath.row].bookSummary ?? "")"

UI Interface

jnpdx
  • 45,847
  • 6
  • 64
  • 94
Abeeget
  • 21
  • 6
  • 1
    Does this answer your question? [Multiple lines of text in UILabel](https://stackoverflow.com/questions/990221/multiple-lines-of-text-in-uilabel) – jnpdx Jan 30 '22 at 09:41
  • I have tried it but I still couldn't get on how to apply it in the line – Abeeget Jan 30 '22 at 09:52

1 Answers1

1

Use \n as you are using in your string. and set the numberOfLines equal to 0 on the detailTextLabel

cell.detailTextLabel?.text = "\(books[indexPath.row].bookAuthor ?? "") \n \(books[indexPath.row].bookSummary ?? "")"

cell.detailTextLabel?.numberOfLines = 0
jnpdx
  • 45,847
  • 6
  • 64
  • 94