Search code examples
iosobjective-cuitableviewuibackgroundcolorxlform

Custom XLForm Section background color


I wish to change the BackgroundColor of a Section (or the Form) within an XLForm.


Section - Multi Valued Row Template.

section.multivaluedRowTemplate.cellConfig[@"backgroundColor"] = kBackgroundColor;


With a row

row.cellConfigAtConfigure[@"backgroundColor"] = kBackgroundColor;


Solution

  • Thanks to a reply on GitHub from @mats-claassen


    Code

    - (void)viewDidLoad {
        [[self tableView] registerClass:[UITableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"headerFooterReuseIdentifier"];
    }
    

    Header

    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
        UITableViewHeaderFooterView *headerFooterView = [[self tableView] dequeueReusableHeaderFooterViewWithIdentifier:@"headerFooterReuseIdentifier"];
        headerFooterView.contentView.backgroundColor = kBackgroundColor;
    
        return headerFooterView;
    }
    

    Footer

    -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
        UITableViewHeaderFooterView *headerFooterView = [[self tableView] dequeueReusableHeaderFooterViewWithIdentifier:@"headerFooterReuseIdentifier"];
        headerFooterView.contentView.backgroundColor = kBackgroundColor;
    
        return headerFooterView;
    }