Is it possible to have a background image used behind a section in a UITableView?
I can't think of how to achieve this.
You can place a view behind your table view, set the table view's background colour to [UIColor clearColor] and you will see the view behind
[self.view addSubview:self.sectionBackgroundView];
[self.view addSubview:self.tableView];
self.tableView.backgroundColor = [UIColor clearColor];
the drawback to this is that this will not be only limited to the section you want, one way I can think of to make sure this backing view is limited to one section only is to adjust the frame of the backing view to the area covered by the section whenever the table view is scrolled
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGRect sectionFrame = [self.tableView rectForSection:sectionWithBackground];
self.sectionBackgroundView.frame = sectionFrame;
}
you will need to do this at the start (probably in viewWillAppear:) as well to make sure the view starts off correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With