Is it possible to vertically align text inside labels with a “large” frame

前端 未结 8 1618
梦谈多话
梦谈多话 2021-01-01 11:58

In my application I have multiple tableviews with custom cells. Some of the text in the cells are spread out on between 2-4 lines so the height of the label is large enough

8条回答
  •  渐次进展
    2021-01-01 12:29

    sizeToFit does not work in UITableCellView, because the Cells are reused during scrolling.

    The solution is to calculate the table cell height according to the font and font size and adjust the label height to it.

    As it was quite difficult to find the solution on the web I wrote a short post about it

提交回复
热议问题