set BackgroundImage to UITableView Section (viewFo

2019-09-18 23:58发布

问题:

I have tried it with

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 100)];
    headerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    headerView.opaque = NO;
    headerView.backgroundColor= [UIColor blackColor];


    return [headerView autorelease];
}

But how can i set a BackgroundImage to the sections?

Thanks much

回答1:

You can set the background colour to a pattern with image:

headerView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myBackground.png"]];