Reputation: 101
What is now the proper way to set the background image for normal and selected states of UITableViewCell? In XCode 4 I used to do it in the IB but now these options are not available.
Upvotes: 0
Views: 2293
Reputation: 1
UIImage *bgImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"image_name" ofType:@"png"]];
UIImageView *av = [[UIImageView alloc] initWithImage:bgImage];
cell.backgroundView = av;
Upvotes: 0
Reputation: 36
I ended up setting the cell.backgroundView:
UIView *backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_background.png"]];
cell.backgroundView = backgroundView;
For the selected state I used the default blue selection.
Upvotes: 2