Impossibility Impossibility - 8 months ago 46
iOS Question

Footer view's color always darker than UITableView separator's color

In my UITableView, I set the separator color like this:

- (void)viewDidLoad {
self.tableView.separatorColor = [UIColor lightGrayColor];

And I set the color of the footer like this:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {

UITableViewHeaderFooterView *footerView = [[UITableViewHeaderFooterView alloc]
initWithFrame:(CGRect){0, 0, 320, 1}];
footerView.contentView.backgroundColor = [UIColor lightGrayColor];

return footerView;

However, the footer view's color is always darker than the separator's color, like this:

enter image description here

How do I get them to be the exact same color? Thanks.


From iOS 6.0 onwards, you can use the below mentioned UITableView's delegate method to change the color of the footer view's background-

- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section 
    //Set the background color of the View
    view.tintColor = [UIColor blueColor];