Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control table section title's indentation in iOS 7?

I suppose that the iOS 7 convention is to make the table cell separators start where the text starts. I wrote the following code to do this:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.separatorInset = 50.0;
}

The problem is that my section titles also get shifted by the same amount. How would I control the indentation of the section titles independently from the cell separators? I would prefer that the section titles be left aligned.

enter image description here

like image 339
Pwner Avatar asked Jan 03 '14 00:01

Pwner


1 Answers

Don't set the separatorInset for the UITableView. Instead, set the separatorInset for the UITableViewCell in the cellForRowAtIndexPath function:

[cell setSeparatorInset:UIEdgeInsetsMake(0, 50, 0, 0)];

Or do it in the story board if you prefer:

enter image description here

like image 134
Mike S Avatar answered Sep 29 '22 07:09

Mike S