转自:http://hi.baidu.com/zhu410289616/item/0de0262910886011097508c2

1.系统默认的颜色设置

//无色

cell.selectionStyle = UITableViewCellSelectionStyleNone;

//蓝色

cell.selectionStyle = UITableViewCellSelectionStyleBlue;

//灰色

cell.selectionStyle = UITableViewCellSelectionStyleGray;

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

改变UITableViewCell选中时背景色:

UIColor *color = [[UIColoralloc]initWithRed:0.0green:0.0blue:0.0alpha:1];//通过RGB来定义自己的颜色

cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];

cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];

3.自定义UITableViewCell选中时背景

cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease];

还有字体颜色

cell.textLabel.highlightedTextColor = [UIColor xxxcolor];  [cell.textLabel setTextColor:color];//设置cell的字体的颜色

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

[theTableView setSeparatorColor:[UIColor xxxx ]];

5.十六进制字符串转uicolor

+(UIColor*)colorWithHexString:(NSString*)hexstring{

NSString*cString = [[hexstring stringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceAndNewlineCharacterSet]] uppercaseString];

// String should be 6 or 8 characters

if([cString length] < 6) return[UIColorblackColor];

// strip 0X if it appears

if([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2];

if([cString hasPrefix:@"#"]) cString = [cString substringFromIndex:1];

if([cString length] != 6) return[UIColorblackColor];

// Separate into r, g, b substrings

NSRangerange;

range.location= 0;

range.length= 2;

NSString*rString = [cString substringWithRange:range];

range.location= 2;

NSString*gString = [cString substringWithRange:range];

range.location= 4;

NSString*bString = [cString substringWithRange:range];

// Scan values

unsignedintr, g, b;

[[NSScannerscannerWithString:rString] scanHexInt:&r];

[[NSScannerscannerWithString:gString] scanHexInt:&g];

[[NSScannerscannerWithString:bString] scanHexInt:&b];

return[UIColorcolorWithRed:((float) r / 255.0f)

green:((float) g / 255.0f)

blue:((float) b / 255.0f)

alpha:1.0f];

}

UITableViewCell的选中时的颜色设置的更多相关文章

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  8. iOS设置cell选中时文字颜色的变化

    cell.titleStr.highlightedTextColor = EMCGreenColor;

  9. notepad++中双击选中字符串高亮颜色设置

    notepad++ 中最好用的功能就是双击选中,本文档中所有相同的内容高亮 不过有个问题就是当文档特别大,而且注释比较多的时候,我选中的内容高亮为绿色不太好找,那怎么设置呢? 设置--语言格式设置-- ...

随机推荐

  1. BZOJ4113 : [Wf2015]Qanat

    设$f_i$表示用$i$个辅助井时代价的最小值,$x_i$表示此时最后一个辅助井的位置. 则$f_i$是关于$x_i$的一个二次函数,其中系数跟$f_{i-1}$有关,递推求出极值点即可. 时间复杂度 ...

  2. BZOJ4382 : [POI2015]Podział naszyjnika

    对于每种颜色,可以发现可以切的位置被分割成了若干段独立的区域. 给每个区域一个编号,将$m$种颜色的情况当成字符串来看,如果两个切口的字符串完全匹配,那么可以在这里切两刀. 可以构造hash函数,通过 ...

  3. echarts.js 做图表的插件

    <scripttype="text/javascript"src="{uiurl()}echarts/echarts.js"></script ...

  4. [Leetcode] Recover Binary Search Tree

    Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing ...

  5. 直接用Qt写soap

    直接用Qt写soap 最近的项目里用到了webservice, 同事用的是`gSoap`来搞的. 用这个本身没什么问题, 但这货生成的代码实非人类可读, 到处都是`__`和`_`, 看得我眼晕.... ...

  6. 内置函数----整理、例题 、xmin

    -----------数值函数 ---绝对值 select abs(-123) from dual; --求模 select mod (12,5) from dual; --取整 --上限值 sele ...

  7. servlet session 相关

    1.session是server维护的一个变量,如果消除每个session?----这里只做指定key的session删除 1.1.显示调用 废除指定key的session session.remov ...

  8. mysql体系结构

    mysql逻辑架构: 第一层,即最上一层,所包含的服务并不是MySQL所独有的技术.它们都是服务于C/S程序或者是这些程序所需要的:连接处理,身份验证,安全性等等. 第二层值得关注.这是MySQL的核 ...

  9. python 获得当前路径

    先要装载 os模块: import os print os.getcwd() 或者 print os.path.abspath(os.curdir) print os.path.abspath('.' ...

  10. 重新初始化RAC的OCR盘和Votedisk盘,修复RAC系统

    假设我们的RAC环境中OCR磁盘和votedisk磁盘全部被破坏,并且都没有备份,那么我们该如何恢复我们的RAC环境.最近简单的办法就是重新初始化我们的ocr盘和votedisk盘,把集群中的所有相关 ...