VARUN ISAC VARUN ISAC - 1 year ago 59
iOS Question

UITableView unwanted white line on each line separator

I have been using the following code for tableview

_comboBoxTableView = [[UITableView alloc] initWithFrame:CGRectMake(1, _selectContentLabel.frame.origin.y+_selectContentLabel.frame.size.height-1, frame.size.width+1, 48) style:UITableViewStylePlain];
_comboBoxTableView.layer.borderColor=[UIColor colorWithRed:226.0/255.0 green:226.0/255.0 blue:226.0/255.0 alpha:1].CGColor;
_comboBoxTableView.layer.cornerRadius = 10;
_comboBoxTableView.layer.borderWidth = 1.0f;
_comboBoxTableView.separatorColor = [UIColor colorWithRed:166.0/255.0 green:166.0/255.0 blue:166.0/255.0 alpha:1];
[_comboBoxTableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];

enter image description here
There is an unwanted white color on the left of each separator as shown below.

Is it a bug? I am running it with ios7.1. Any work around ?

Answer Source

It's not a bug. As of iOS 7, table views are capable of adjusting the insets of their separators. If you want an edge to edge separator, eliminate the insets:

if ([_comboBoxTableView respondsToSelector:@selector(separatorInset)]) { // In case running iOS < 7
    _comboBoxTableView.separatorInset = UIEdgeInsetsZero;

More info in the UITableView documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download