bolshas
bolshas

Reputation: 101

Xcode 4.2 UITableViewCell background

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

Answers (2)

user2457636
user2457636

Reputation: 1

UIImage *bgImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"image_name" ofType:@"png"]];

UIImageView *av = [[UIImageView alloc] initWithImage:bgImage];

cell.backgroundView = av;

Upvotes: 0

Itay kopel
Itay kopel

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

Related Questions