How to create padding(spacing) between rows in tablview

Many ways to do it, but I found this is the simplest and easiest way to do so.

Set UITableView style grouped. Then have two sections and each section has only one row. Replace your image in the row.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    //array is your db, here we just need how many they are
    return [array count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //place your image to cell
}
- (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    //this is the space
    return 50;
}

Simply make the content of your cell clearcolor and give yourself padding by adding height. Add the background image (or color) of your cell however you'd like afterwards by inserting a new view or label of shorter height.

This way you can maintain a table with multiple sections and multiple rows.


You can do it in just 3 lines.

First set gray color of your main view after that follow these lines.

cell.separatorInset = UIEdgeInsetsMake(20, 20, 20, 20);
cell.layer.borderWidth = 5;
cell.layer.borderColor = [UIColor whiteColor].CGColor;