【发布时间】:2011-11-10 16:41:06
【问题描述】:
How to customize the background/border colors of a grouped table view cell?
阅读这篇文章后,我尝试使用此解决方案。这是我的代码,在 tableViewDelegate 方法中:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCellBackgroundView *customBackground = [CustomCellBackgroundView alloc];
[customBackground setBorderColor:[UIColor blackColor]];
[customBackground setFillColor:[UIColor redColor]];
[customBackground setPosition:0]; //i'll deal with that later
[cell setSelectedBackgroundView:customBackground];
[customBackground release];
UIImageView* selectedBackgroundCell = [[[UIImageView alloc] initWithFrame:CGRectNull] autorelease];
[selectedBackgroundCell setImage:[UIImage imageNamed:@"cell_bg_50_hover.png"]];
[customBackground drawRect:selectedBackgroundCell.frame];
[cell setSelectedBackgroundView:selectedBackgroundCell];
//standard background color
[cell setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_bg_50.png"]]];
}
但不幸的是,它并没有改变任何东西。你知道我做错了什么吗?
【问题讨论】: