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