Separation between Header and first cell -- In plain UITableView Separation between Header and first cell -- In plain UITableView ios ios

Separation between Header and first cell -- In plain UITableView


As Jeremy notes in his answer, iOS doesn't add separators above/below the headers/footers; you can just use a UIView to create a line yourself.

Here's the code to add a standard looking separator view to a header view:

CGRect sepFrame = CGRectMake(0, headerView.frame.size.height-1, 320, 1);seperatorView = [[[UIView alloc] initWithFrame:sepFrame] autorelease];seperatorView.backgroundColor = [UIColor colorWithWhite:224.0/255.0 alpha:1.0];[headerView addSubview:seperatorView];

If you're trying to make it look like a normal table view cell, you probably need to add one at the top of the header view too.


Custom headers and footers do not contain separators below/above them. You'll need to implement the separator yourself in the custom view (or switch to grouped style, which will show the outline of the group above and below it even with a custom header/footer).


if you want to give space only between table header and table first row then you can use

In method of tableView:heightForHeaderInSection:(NSInteger)section

if(section ==0)    return 3; // (space u want to give between header and first row);return 10; //(ur section header height)

In method of tableView:viewForHeaderInSection:(NSInteger)section

  UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 3)];  headerView.backgroundColor = [UIColor clearColor];   // use your own design  return headerView;