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.
Asked
Active
Viewed 2,291 times
0
-
Does this help? : http://stackoverflow.com/questions/894875/how-can-i-set-the-background-of-uitableview-the-tableview-style-is-grouped-to – trojanfoe Oct 14 '11 at 16:03
-
It talks about the uitableview - not the cell. I was wondering about the recent change in xcode that there is no place to choose the background image in the IB. – bolshas Oct 14 '11 at 16:56
2 Answers
2
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.

fredley
- 32,953
- 42
- 145
- 236

Itay kopel
- 36
- 1
0
UIImage *bgImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"image_name" ofType:@"png"]];
UIImageView *av = [[UIImageView alloc] initWithImage:bgImage];
cell.backgroundView = av;