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]
4. Set the color of the split line between Tableviewcell
- [Thetableview Setseparatorcolor:[uicolor xxxx]];
5. Set the color of the font in the cell
Prettyprint Code
- <span style="Color: #888888;"class="com" > Customize the appearance of table view cells.</span><span style= "color: #000000;" class= "pun" >-</span><span style= "color: #000000;" class= "pun" > (</span><span style= "color: #000088;" class= "Typ" >uitableviewcell</span><span style= "color: #000000;" class= "pun" >*) </span><span style= "color: #000000;" class= "PLN" >tableview</span><span style= "color: #000000;" class= "pun" >:(</span><span style= "color: #000088;" class= "Typ" >uitableview</span><span style= "color: #000000;" class= "pun" >*) </span><span style= "color: #000000;" class= "PLN" >tableview cellforrowatindexpath</span><span style= "color: #000000 ;" class= "pun" >:(</span><span style= "color: #000088;" class= "Typ" >nsindexpath</span><span style= "color: #000000;" class= "pun" >*) </span><span style= "color: #000000;" class= "PLN" >indexPath
- </span><span style="color: #000000;" class="pun" >{</span><span style="color: #000000;" class="PLN" >
- </span><span style="Color: #880000;"class="KWD" >If</span><span style="Color: #000000;"class="Pun" > (</span><span style="Color: #006666;"class="Lit" >0</span><span style= "color: #000000;" class= "pun" >==</span><span style= "color: #000000;" class= "PLN" > indexPath</span><span Style= "color: #000000;" class= "pun" >.</span><span style= "color: #000000;" class= "PLN" >row</span><span style= "color: #000000;" class= "pun" >) </span><span style= "color: #000000;" class= "PLN" >&NBSP;
- </span><span style="color: #000000;" class="pun" >{</span><span style="color: #000000;" class="PLN" >
- Cell</span><span style="Color: #000000;"class="Pun" >.</span><span style= "color: #000000;" class= "PLN" >textlabel</span><span style=< Span class= "string" > "color: #000000;" class= "pun" >.</span><span style= "color: #000000;" class= "PLN" >textColor </span><span Style= "color: #000000;" class= "pun" >=</span><span style= "color: #000000;" class= "pun" >...; </span><span style= "color: #000000;" class= "PLN" >&NBSP;
- Cell</span><span style="Color: #000000;"class="Pun" >.</span><span style= "color: #000000;" class= "PLN" >textlabel</span><span style=< Span class= "string" > "color: #000000;" class= "pun" >.</span><span style= "color: #000000;" class= "PLN" >highlightedTextColor </span>< Span style= "color: #000000;" class= "pun" >=</span><span style= "color: #000000;" class= "pun" >...; </span><span style= "color: #000000;" class= "PLN" >&NBSP;
- </span><span style="color: #000000;" class="pun" >}</span><span style="color: #000000;" class="PLN" >
- </span><span style="color: #000000;" class="pun" >...</span><span style="color: #000000;" class="pun" >}</span>
The color settings for iOS development UITableViewCell when selected