I just bought a book and learn programming IOS in Swift. I want to create a table view list like snapchat:
Then I set the all of the constrain of the UITableView to 0:
However, there is still a margin on left of the table, why?
I just bought a book and learn programming IOS in Swift. I want to create a table view list like snapchat:
Then I set the all of the constrain of the UITableView to 0:
However, there is still a margin on left of the table, why?
Search for Separator inset in interface builder after clicking on the UITableView
And change it to Custom. Now you can set the Left Inset to 0
in viewDidLoad
[tableView setSeparatorInset:UIEdgeInsetsZero];
Add Following Code in cellForRowAtIndexPath:
if ([cell respondsToSelector:@selector(preservesSuperviewLayoutMargins)]){
cell.layoutMargins = UIEdgeInsetsZero;
cell.preservesSuperviewLayoutMargins = false;
}
if ([UITableView instancesRespondToSelector:@selector(setLayoutMargins:)]) {
[[UITableView appearance] setLayoutMargins:UIEdgeInsetsZero];
[[UITableViewCell appearance] setLayoutMargins:UIEdgeInsetsZero];
[[UITableViewCell appearance] setPreservesSuperviewLayoutMargins:NO];
}
As @Ashish Kakkad pointed out, it's about the SeparatorInsets
, I just wanted to add here, that you can also set them in Storyboard, you don't have to do this in code.
Search for Separator inset in interface builder after clicking on the table view
And change it to Custom
. Now you can set the Left Inset to 0