Cell background
I am trying to got own background for every cell but it looks like:
Here's the code I'm working with
cell.team1Label.backgroundColor = [UIColor clearColor];
cell.team2Label.backgroundColor = [UIColor clearColor];
cell.dateLabel.backgroundColor = [UIColor clearColor];
cell.timeLabel.backgroundColor = [UIColor clearColor];
cell.stadiumLabel.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell.开发者_C百科png"]];
Thanks
Looking at the UITableViewCell
class reference, there's a property called backgroundView
that should be the thing you're looking for.
UIImageView *background = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"image"];
[cell setBackgroundView: background];
[background release];
There's a property called selectedBackgroundView
as well, which is used instead of the regular one, when the cell is selected/highlighted.
EDIT: Just tried this code, at least it's working when the cell has one label inside of it. Not sure about multiple, but if you haven't added any other views to the cell it should work as intended.
add this:
cell.contentView.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor colorWithPatternImage...
Try
cell.backgroundColor = [UIColor colorwithPatternImage:[UIImage imageNamed:@"cell.png"]];
If you are creating a custom cell then you can set your image in uiimageview in the cell itself. It will work as background image... :)
精彩评论