简体   繁体   中英

UITableViewHeaderFooterView appearance

I'm using the following code [[UITableViewHeaderFooterView appearance] setTintColor:[UIColor whiteColor]]; at the end of didFinishLaunchingWithOptions to set the tint color of a custom UITableViewHeaderFooterView my main problem is when i'm scrolling the table view and for example section 0 gets off the screen then reverts to default gray color any ideas how to fix this my reusable code is very basic

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
 {
    ListSectionHeaderView *sectionHeaderView = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:@"ListSectionHeaderView"];
 }

you have to create the header footer first run then reuse it

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

    ListSectionHeaderView *sectionHeaderView = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:@"ListSectionHeaderView"];
    if (!sectionHeaderView)
    {
         //// initialize the header here if the reuse return nil 
         sectionHeaderView = ....
    }
    ///// also you have to return it
    return sectionHeaderView;
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM