So in a UITableViewCell subclass this works great:
- (void)awakeFromNib {
[super awakeFromNib];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"table-highlight.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]];
imageView.contentMode = UIViewContentModeScaleToFill;
self.selectedBackgroundView = imageView;
}
However I have a tableView that just uses standard table cells that aren’t subclassed. I’ve tried all sorts of combinations of this as found in other answers with no luck:
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"table-highlight.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]];
imageView.contentMode = UIViewContentModeScaleToFill;
cell.selectedBackgroundView = imageView;
}
Damn. Thought of one thing 30 seconds after posting this. Leaving it up in case it helps someone else. My imageView didn’t have a frame on it. Working code: