Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 986
Impossibility Avatar asked Apr 08 '15 05:04

Impossibility


1 Answers

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];
}
like image 138
Sanjay Mohnani Avatar answered Oct 14 '22 05:10

Sanjay Mohnani