Steps 1 & 2 below have already been said by others, but I'm going to say it here anyway for completeness of my answer.
Step 1, set the table view background to transparent:
self.tableView.backgroundColor = [UIColor clearColor];
Step 2, as you stated you already have, you must set the height by overriding the heightForHeaderInSection
method (in your case, 10):
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 50.0;
}
Step 3, provide a custom view by overriding the viewForHeaderInSection
method (note -- this is where you must set the background color to clear):
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.oTableView.frame.size.width, 10)];
header.backgroundColor = [UIColor clearColor];
return header;
}
Step 4, once you verify that this is, in fact, showing a transparent background (you'll see the view below this in the background just as you see above and on the sides of the table view), you then focus on creating the effect that you want at the top and bottom of the cells.
You can do this in one of two ways:
- Modify your
UITableViewCell
implementation to create rounded corners (only top left and top right if the first cell in a section; only bottom left and bottom right if the last cell in a section).
- Customize the custom view you are creating in the
viewForHeaderInSection
override to provide the rounded corner effects (add subviews to the header
view that you return in this method), but this will add more space at the top (first cell) or top & bottom (last cell) of cells in a section.