By default there is a single line separator in uitableview.
But I want to put my customized line as a separator.
Is it possible? How?
These answers result in the highlight rect being overwritten by the separator you add to your cell (on iOS 6 with my testing at least). You need to set the separatorColor to [UIColor clearColor] so that cells are still separated by 1px, you can then draw your separator in the gap:
- (void)viewDidLoad {
self.tableView.separatorColor = [UIColor clearColor];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// snip
CALayer *separator = [CALayer layer];
separator.backgroundColor = [UIColor redColor].CGColor;
separator.frame = CGRectMake(0, 43, self.view.frame.size.width, 1);
[cell.layer addSublayer:separator];
return cell;
}