Home > Mobile >  How do I add new line in a UILabel inside a UITableViewCell?
How do I add new line in a UILabel inside a UITableViewCell?

Time:01-30

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

CodePudding user response:

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
  •  Tags:  
  • Related