How to add line break for UILabel?

后端 未结 21 2187
失恋的感觉
失恋的感觉 2020-11-29 14:53

Let see that I have a string look like this:

NSString *longStr = @\"AAAAA\\nBBBBB\\nCCCCC\";  

How do I make it so that the UILabel disp

21条回答
  •  忘掉有多难
    2020-11-29 15:26

    // DO not forget to set numberOfLines to zero

    UILabel* locationTitle = [[UILabel alloc] initWithFrame:CGRectMake(5, 30, 230, 40)];
    locationTitle.font = [UIFont systemFontOfSize:13.0];
    locationTitle.numberOfLines = 0;
    locationTitle.text = [NSString stringWithFormat:@"Eaton industries pvt. Ltd \nUK Apr 12"];
    [cell addSubview:locationTitle];
    

提交回复
热议问题