Calculating multiline text height for UILabel/UITableViewCell: different results when calculating vs actual drawing

前端 未结 3 889
情深已故
情深已故 2021-01-30 05:09

This general topic has been asked here multiple times: how to render UITableViewCells with varying amount of text and thus varying height. The canonical answer is: you calculate

3条回答
  •  面向向阳花
    2021-01-30 05:56

    For multiline labels you need set

    cell.textLabel.numberOfLines = 0;
    

    and then

    [cell.textLabel sizeToFit];
    

    But for pretty view you need add some padding pixels. And your app will be awesome!

提交回复
热议问题