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

 

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的选中时的颜色设置

    原文网址:http://mobile.51cto.com/hot-404900.htm 1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSe ...

  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:扩展UIColor,支持十六进制颜色设置

    来自转载:http://my.oschina.net/leejan97/blog/307491 摘要: 可以直接使用十六进制设置控件的颜色,而不必通过除以255.0进行转换 #define UICol ...

随机推荐

  1. IO多路复用 select、poll、epoll

    什么是IO多路复用 在同一个线程里面, 通过拨开关的方式,来同时传输多个(socket)I/O流. 在英文中叫I/O multiplexing.这里面的 multiplexing 指的其实是在单个线程 ...

  2. React Native学习之DeviceEventEmitter传值

     使用DeviceEventEmitter前需添加 import { AppRegistry, StyleSheet, Text, View, DeviceEventEmitter } form 'r ...

  3. HashMap源码-使用说明部分

    /* * Implementation notes. * 使用说明 * * This map usually acts as a binned (bucketed) hash table, but * ...

  4. STM3的Uart中断接受数据和非中断接受数据!

    //非中断方式接受数据if(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == SET) //接收数据寄存器非空标志位{ str = USART_Recei ...

  5. UI控件---UIWebView

    UIWebView是内置浏览器控件,可以用来浏览网页,文档等,今天就试着做一个简易的浏览器! 定义url的初始化方法和返回,前进,刷新三个方法,实现UIWebViewDelegate协议 @inter ...

  6. ibatis传入list对象

    在使用ibatis的时候经常需要传入list对象,sql语句如下. <select id="GET-PERSONS" parameterClass="java.ut ...

  7. 一起來玩鳥 Starling Framework(9)Particle

    最後,來看看Starling裡一個很炫的功能:Particle.Particle屬於extension,所以要另外下載檔案:Starling-Extension-Particle-System.下載之 ...

  8. 最短路径——Floyd,Dijkstra(王道)

    题目描述: 在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt.但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线 ...

  9. [转载]linux 更新yum源 改成阿里云源

    原文链接:https://www.cnblogs.com/bincoding/p/7892762.html 1.备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc ...

  10. java web程序中项目名的更改(http://localhost:8080/)后面的名字

    在MyEclipse中的Web项目,如果想另换名称(Context-root)进行发布,可以在项目的属性中进行设置.设置路径如下: 右击项目XX(或选中项目XX,按快捷键Alt+Enter), 打开项 ...