Why is the contentView height of the UITableViewCell always one point less than the UITableViewCell?

My cells at the UITableViewCell level are 44 points high. ContentView says 43 points and he sat in IB. How can I make the content the same size as the cell?

Please note that I design my cells in separate xib files.

I want my cells to have no margin between them.

I also set None as the table separator style. The row height in IB is also 44 points. Do not use any sections.

+3


source to share


2 answers


If you are using storyboards , then the Separator

tableView to parameter None

(instead of Default

) gets rid of the 1pt separator and the contentView's height becomes equal to the cell's height (even if it's greyed out)



Note. This solution doesn't work with xib files (at least doesn't update IB, didn't check at runtime).

+7


source


I understood that. I used full size background images as backgrounds for the cells. Once I stopped putting a separate UIImageView: s as the background in the contentView and instead assigned the background UIImageView: s to the cell's backgroundView property and then set the cell height as well as the height of each cell in the uitableview (and also set the contentView's background color to fully transparent! ), it all started as I wanted. The contentView's height will still be one point less, but now the cells are perfectly aligned with each other. For this I don't need the contentView height to match the UITableViewCell height.



0


source







All Articles