Search code examples
iosswiftuilabel

How to apply new line bettwen paranthesis string?


I am trying to split player name in two lines, But no luck

cell.lblHomeTeam.text = "\(model.player_name!) \n  \(model.replaced_player_name!)"

Current output

Player1 \n Player2

Required Output

Player1
Player2

Solution

  • You need to set

    cell.lblHomeTeam.numberOfLines = 0
    

    the wrapping also depend on how you set constraints , so it should be either a leading & fixed width or a trailing & fixed width or leading & trailing