IPhone - insert space between user table cells in UITableView

I have a UITableView with custom cells. I would like to add a little red stripe between the cells to make the cells more distinct.

Is there an easy way to do this?

Thanks!

+4
source share
2 answers

Use the separatorStyle and separatorColor properties for a UITableView . For instance:

 - (void) viewDidLoad { self.tableView.separatorColor = [UIColor redColor]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; } 

This style by default, there are others, but depending on which OS you are targeting (for example, the etching style is available only with 3.2).

Apple Docs in UITableView

0
source

1- Override

 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

If indexPath.row% 2 == 1 (a line with an odd index), delete the text in your cell, set the background color to red and return that cell. If you are filling the table with an array, you must consider these additional red cells and fill them accordingly.

2 - Write a custom UITableView cell with extra red space at the bottom and return this cel to cellForRowAtIndexPath. If necessary, remove the red space in the bottom cell.

-1
source

All Articles