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. 1.1(Spring学习笔记)Spring基础(BeanFactory、ApplicationContext 、依赖注入)

    1.准备工作 下载Spring:http://repo.spring.io/libs-release-local/org/springframework/spring/    选择需要下载的版本    ...

  2. Scala实战高手****第1课:大数据时代的“黄金”语言Scala

    共计28课,每节课程在1个小时左右. 每天至少2个课程.预计在11.30号完成. ——————————————————

  3. sql server博客

    SQLSERVER MSDN论坛 SQLSERVER 补丁博客 SQLSERVER中国研发中心 微软亚太区数据库技术支持组官方博客 PAUL的SQLSKILL网站 sqlsaturday网站 sqls ...

  4. SQLSERVER LATCH WINDBG

    https://mssqlwiki.com/2012/09/07/latch-timeout-and-sql-server-latch/

  5. delphi执行cmd命令和bat文件

    转载地址:http://blog.csdn.net/hutao1101175783/article/details/42807063 cmd:='echo d | Xcopy '+BasePath+' ...

  6. javascript 定时器 笔记

    最近想看下定时器,发现这东西越看越牵连的东西越多,比如js单线程,EVent loop 什么的 看到了几篇比较好的文章 http://ejohn.org/blog/how-javascript-tim ...

  7. flask前端优化:css/js/html压缩

    1.先压缩再传输,可以减少传输的大小,减少传输时间,但是压缩需要时间,所以最终页面显示是快了还是慢了,需要比较 2.先看html压缩模块:pip install Flask-HTMLmin 压缩前:大 ...

  8. fedora25安装和docker-ce_清华源

    docker-ce_清华源 https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/fedora/ fedora25 docker-ce版本: htt ...

  9. js 正则只允许小写字母、数字、点、中短划线

    正则表达式如下: /^[a-z0-9\.-]*$/g 可用如下语句验证: alert(/^[a-z0-9\.-]*$/g.test('abc123.45a-b')); //true alert(/^[ ...

  10. 解决 The &#39;InnoDB&#39; feature is disabled; you need MySQL built with &#39;InnoDB&#39; to have it working

    事由: 迁移server的时候须要操作数据库.将数据库也进行迁移,在新server中导入数据的时候提示 The 'InnoDB' feature is disabled; you need MySQL ...