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"]]];
}
但不幸的是,它不会改变任何东西。你知道我做错了什么吗?
它没有帮助。谢谢。 –
感谢您的写作....我与代码并改变了我的答案。请检查天气是否有帮助.... – Mohammad
不要忘记发送'autorelease'到bkview! – mvds