1. System default color settings
- Colorless
- Cell.selectionstyle = Uitableviewcellselectionstylenone;
- Blue
- Cell.selectionstyle = Uitableviewcellselectionstyleblue;
- Grey
- Cell.selectionstyle = Uitableviewcellselectionstylegray;
2. Custom color and background settings
Change UITableViewCell background color When selected:
Uicolor *color = [[Uicoloralloc]initwithred:0.0green:0.0blue:0.0alpha:1]; //Use RGB to define your own colors
- Cell.selectedbackgroundview = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
- Cell.selectedBackgroundView.backgroundColor = [Uicolor xxxxxx];
3 Custom UITableViewCell Background When selected
- Cell.selectedbackgroundview = [[[Uiimageview alloc] initwithimage:[uiimage imagenamed:@ "Cellart.png"]] autorelease];
- and a font color.
- Cell.textLabel.highlightedTextColor = [Uicolor Xxxcolor]; [Cell.textlabel settextcolor:color];//sets the color of the cell's font
4. Set the color of the split line between Tableviewcell
[Thetableview Setseparatorcolor:[uicolor xxxx]];
4.pop cell automatically unchecked when returned to table
First I have a uitableviewcontroller, where each UITableViewCell click will push another viewcontroller, each time you click on the cell, the cell will be selected, When returned from the push Viewcontroller, the selected cell is automatically unchecked. Later, for some reason, I changed this uitableviewcontroller to Uiviewcontroller, and then there was a problem: each time I returned to TableView, the previously selected cell could not be automatically unchecked and was found to know:
Uitableviewcontroller has a Clearsselectiononviewwillappear property,
And when the Uitableviewcontroller is modified to Uiviewcontroller, this attribute naturally does not exist, so we have to manually add the unchecked function, the method is simple, in the Viewwillappear method to add:
[Self.tableview Deselectrowatindexpath:[self.tableview Indexpathforselectedrow] Animated:YES];
6.after clicking, after a period of timeCellautomatically uncheck
-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{
............
Eliminate cell selection traces
[Self Performselector: @selector (deselect) Withobject:nil afterdelay:0.5f];
}
-(void) deselect
{
[Self.tableview Deselectrowatindexpath:[self.tableview Indexpathforselectedrow] Animated:YES];
}
UITableView color settings and cell auto-unchecked state