Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView top and button separator inset not working

I'm trying to set insets in my tableview so that each cell does not stick to each other.

To do this, I've added the following method to my tableView:willDisplayCell:forRowAtIndexPath:

if([tableView respondsToSelector:@selector(setSeparatorInset:)]){
    [tableView setSeparatorInset:UIEdgeInsetsMake(10, 15, 10, 15)];
}

I basically want a 10pt space on the top and bottom of the cell, before the next cell. This code partially works, because there is a visible 15pt inset on the left and right. However, the top and bottom are still connected.

Thanks!

~Carpetfizz

like image 520
Carpetfizz Avatar asked Jan 28 '26 23:01

Carpetfizz


1 Answers

The top and bottom values are ignored UITableViewCell Class Reference (separatorInset):

[...]Only the left and right inset values are respected; the top and bottom inset values are ignored.[...]

I'd recommend to do the spacing by increasing the height of the cells and place the content with an appropriate padding to the top and bottom edge.

like image 113
Florian Mielke Avatar answered Jan 30 '26 16:01

Florian Mielke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!