原文网址:http://mobile.51cto.com/hot-404900.htm

1.系统默认的颜色设置

  1. //无色
  2. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  3. //蓝色
  4. cell.selectionStyle = UITableViewCellSelectionStyleBlue;
  5. //灰色
  6. cell.selectionStyle = UITableViewCellSelectionStyleGray;

2.自定义颜色和背景设置

改变UITableViewCell选中时背景色:

  1. UIColor *color = [[UIColoralloc]initWithRed:0.0green:0.0blue:0.0alpha:1];//通过RGB来定义自己的颜色
  2. cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
  3. cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];

3.自定义UITableViewCell选中时背景

  1. cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease];
  2. 还有字体颜色
  3. cell.textLabel.highlightedTextColor = [UIColor xxxcolor]; [cell.textLabel setTextColor:color]

4.设置tableViewCell间的分割线的颜色

  1. [theTableView setSeparatorColor:[UIColor xxxx ]];

5、设置cell中字体的颜色

Prettyprint代码

  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">
  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="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">
  6. cell</span><span style="color: #000000;" class="pun">.</span><span style="color: #000000;" class="pln">textLabel</span><span style="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">
  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>

【转】iOS开发UITableViewCell的选中时的颜色设置的更多相关文章

  1. iOS开发UITableViewCell的选中时的颜色设置(转)

    iOS开发UITableViewCell的选中时的颜色设置   1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyle ...

  2. iOS开发UITableViewCell的选中时的颜色设置

    1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = ...

  3. UITableViewCell的选中时的颜色设置

    转自:http://hi.baidu.com/zhu410289616/item/0de0262910886011097508c2 1.系统默认的颜色设置 //无色 cell.selectionSty ...

  4. IOS - UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte

    1.系统默认的颜色设置 [cpp] view plaincopy //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 ...

  5. iOS设置UITableViewCell的选中时的颜色

    1.系统默认的颜色设置 //无色   cell.selectionStyle = UITableViewCellSelectionStyleNone;     //蓝色   cell.selectio ...

  6. UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte

    1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = ...

  7. iOS开发UI篇—iOS开发中三种简单的动画设置

    iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView b ...

  8. iOS UITabBarItem 选中图的颜色,设置UIimage的渲染模式

    UITbarController之前有在这篇文章讲解:http://www.cnblogs.com/niit-soft-518/p/4447940.html 如果自定义了UITabBarItem的图片 ...

  9. IOS开发中滑动页面时NSTimer停止的问题

    我们在做倒计时的时候,发现当你手指按着屏幕不放,拖动tableView滑动的时候,写在cell上得倒计时停止倒计时,松开继续倒计时.研究发现就是拖动tableView滑动时,NSTimer停止了. 这 ...

随机推荐

  1. HTTP长轮询和短轮询

    http 协议介绍: http 协议是请求/响应范式的, 每一个 http 响应都是由一个对应的 http 请求产生的; http 协议是无状态的, 多个 http 请求之间是没有关系的. http ...

  2. POJ2299Ultra-QuickSort

    http://poj.org/problem?id=2299 题意 : 排序,求排序次数,本来以为用冒泡可以搞定,事实上,那么大的数据以及一个TLE告诉我,会超时......... 思路 : 问了一下 ...

  3. Android 打开闪光灯(手电筒)

    package com.example.openBackLight; import android.app.Activity; import android.hardware.Camera; impo ...

  4. Oracle 6 - 锁

    Oracle锁没有额外的开销?Oracle的锁是怎么实现的?因为其他数据库,锁都是一种稀有资源和开销. 答:代码级实现?? 没有锁的话,并发更新就会有丢失更新的问题. 悲观锁和乐观锁 悲观锁一般用于有 ...

  5. [转]Ubuntu alternate和desktop区别

    原文地址:http://blog.csdn.net/is2120/article/details/6797621 Desktop : 刻录在光盘,从光盘运行的系统,相当于 Live CD Altern ...

  6. Project Euler 100 : Arranged probability 安排概率

    Arranged probability If a box contains twenty-one coloured discs, composed of fifteen blue discs and ...

  7. LeeCode 1-Two Sum

    Two Sum Total Accepted: 125096 Total Submissions: 705262 Question Solution Given an array of integer ...

  8. [itint5]最短路径遍历点

    http://www.itint5.com/oj/#50 此题有点难,参考了这篇文章,是个两条路的DP: http://blog.csdn.net/a83610312/article/details/ ...

  9. 【nginx网站性能优化篇(3)】反向代理实现负载均衡

    注意,本篇文章为负载均衡的理论篇,后续找个机会推出实战篇.理论篇主要讲述如何配置负载均衡,配置负载均衡不难.难的是真正的实战,比如如何做到多服务器之间的数据共享(session,file等),多cac ...

  10. python 处理 Excel 表格

    see: http://www.cnblogs.com/sunada2005/p/3193300.html 一.可使用的第三方库 python中处理excel表格,常用的库有xlrd(读excel)表 ...