The color settings for iOS development UITableViewCell when selected

Source: Internet
Author: User

1. System default color settings

    1. Colorless
    2. Cell.selectionstyle = Uitableviewcellselectionstylenone;
    3. Blue
    4. Cell.selectionstyle = Uitableviewcellselectionstyleblue;
    5. Grey
    6. Cell.selectionstyle = Uitableviewcellselectionstylegray;

2. Custom color and background settings

Change UITableViewCell background color When selected:

    1. Uicolor *color = [[Uicoloralloc]initwithred:0.0green:0.0blue:0.0alpha:1]; //Use RGB to define your own colors
    2. Cell.selectedbackgroundview = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
    3. Cell.selectedBackgroundView.backgroundColor = [Uicolor xxxxxx];

3. Custom UITableViewCell Background When selected

    1. Cell.selectedbackgroundview = [[[Uiimageview alloc] initwithimage:[uiimage imagenamed:@"Cellart.png"]  Autorelease];
    2. and a font color.
    3. Cell.textLabel.highlightedTextColor = [Uicolor Xxxcolor]; [Cell.textlabel Settextcolor:color]

4. Set the color of the split line between Tableviewcell

    1. [Thetableview Setseparatorcolor:[uicolor xxxx]];

5. Set the color of the font in the cell

Prettyprint Code

  1. <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 
  2. </span><span style="color: #000000;" class="pun" >{</span><span style="color: #000000;" class="PLN" >
  3. </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;
  4. </span><span style="color: #000000;" class="pun" >{</span><span style="color: #000000;" class="PLN" >
  5. 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;
  6. 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;
  7. </span><span style="color: #000000;" class="pun" >}</span><span style="color: #000000;" class="PLN" >
  8. </span><span style="color: #000000;" class="pun" >...</span><span style="color: #000000;" class="pun" >}</span>

The color settings for iOS development UITableViewCell when selected

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.