1

UITableViewCell separator insets don't work when table.width is much greater than view.width on iOS 10, I haven't try it on the device which iOS version is less then iOS 10.

enter image description here

code is here on gist

Kevin Hawk
  • 308
  • 2
  • 10
  • the separator line if full, when tableview.width=600,but if the width is greater than 700,the separator shows the insets on the left and right sides. i tried it on the iPhone5S – Kevin Hawk Mar 14 '17 at 10:39

3 Answers3

2

You can add separator in your UITableView using the below code

 UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 3)];/// change size as you need.       
 separatorLineView.backgroundColor = [UIColor whiteColor];// you can also put image here
 [cell.contentView addSubview:separatorLineView];

and remove the default separator of your UITableView. Hope it helps.

Pradumna Patil
  • 2,180
  • 3
  • 17
  • 46
  • Yes, thx. I know custom separator line work well. But I want to know why system separator line have insets. – Kevin Hawk Mar 14 '17 at 10:48
1
_tableView.cellLayoutMarginsFollowReadableWidth = NO;

it works above.

refer to

iOS 9 UITableView separators insets (significant left margin)

Xcode 7 iOS 9 UITableViewCell Separator Inset issue

Community
  • 1
  • 1
Kevin Hawk
  • 308
  • 2
  • 10
0

There are two ways in which you can solve this problem.

First one you can add a separator line view in cell content view.

 UIView* line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableview.frame.size.width, 3)];      
 line.backgroundColor = [UIColor whiteColor];

[cell.contentView addSubview:line];

The second one is apple provided one and pretty easy also just add this line of code where u declare your tableview

yourTableView.cellLayoutMarginsFollowReadableWidth = NO;
Pradumna Patil
  • 2,180
  • 3
  • 17
  • 46
iamgautam
  • 90
  • 1
  • 11