Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom UITableViewCell - Add margin between each cell

Is it possible to apply a margin between UITableView cells?

The brief requires the table cells to look like below -

enter image description here

I have a custom cell class to style the background / fonts / separate labels - but cannot figure out how to apply any kind of spacing!

like image 805
Dancer Avatar asked Mar 22 '23 21:03

Dancer


1 Answers

I woud do it the following way: first, make sure background color for both your UITableViewCell and its contentView is [UIColor clearColor], then add a subview slightly smaller than your cell contentView (so that height = CGRectGetHeight(contentView) - margin) and fill it with the color you need. Then set the backgroundView for your UITableView and this should do the trick.

like image 156
dariaa Avatar answered Apr 02 '23 19:04

dariaa