Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AdityaDeshmane/78aa8ab443d49b8bbd0e to your computer and use it in GitHub Desktop.
Save AdityaDeshmane/78aa8ab443d49b8bbd0e to your computer and use it in GitHub Desktop.
iOS : UITableView Set / Reset Separator Margins
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Remove seperator inset
if ([cell respondsToSelector:@selector(setSeparatorInset:)])
{
[cell setSeparatorInset:UIEdgeInsetsZero];
}
// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)])
{
[cell setPreservesSuperviewLayoutMargins:NO];
}
// Explictly set your cell's layout margins
if ([cell respondsToSelector:@selector(setLayoutMargins:)])
{
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment