Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 235
VARUN ISAC Avatar asked Jun 27 '14 13:06

VARUN ISAC


1 Answers

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.

like image 113
Mick MacCallum Avatar answered Oct 25 '22 15:10

Mick MacCallum