I have tried to set the separator inset on the right. Upon the first run of the project and before scrolling the tableview, everything appears smooth. But then as soon as the scrolling happens once, the separator inset of the last row in each section resizes to take the full width.
The code used is as below :
In viewDidLoad
:
myTable.separatorColor = [UIColor redColor];
[myTable setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 40)];
Inside cellForRowAtIndexPath
:
[tableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 40)];
cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, 40);
I tried putting the same code in almost all other delegate/datasource methods of UITableView
but to no avail.
To do the inset thingy in the headerview of the table, I have added two UILabel
upper and lower with restricted frame width in viewForHeaderInSection
(height of header being 40):
UILabel *upperBorder = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 280.0, 1.0)];
[upperBorder setBackgroundColor:[UIColor blackColor]];
[headerView addSubview:upperBorder];
UILabel *lowerBorder = [[UILabel alloc]initWithFrame:CGRectMake(0, 39.0, 280.0, 1.0)];
[lowerBorder setBackgroundColor:[UIColor blackColor]];
[headerView addSubview:lowerBorder];
I have put the images before and after scrolling.
Before scrolling :
After scrolling :
Any help in this regard is appreciated. I simply need to make the table look like the first pic even after scrolling i.e. to retain the edge inset in the right side no matter what. Thanks in advance.