转自: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. C++可能出错的小细节

    1. for(list<Geometry_line>::iterator it = G.begin(); it != G.end();) { if(IsLineCrossed(*it, l ...

  2. mysql 的 find_in_set函数使用方法

    举个例子来说: 有个文章表里面有个type字段,他存储的是文章类型,有 1头条,2推荐,3热点,4图文 .....11,12,13等等 现在有篇文章他既是 头条,又是热点,还是图文, type中以 1 ...

  3. 笔记本做wifi热点

    你可以开启windows 7的隐藏功能:虚拟WiFi和SoftAP(即虚拟无线AP),就可以让电脑变成无线路由器,实现共享上网.点开始 所有程序 命令提示符右键管理员身份运行命令提示符 运行命令:ne ...

  4. -webkit-text-size-adjust:none;

  5. CF 7C. Line(扩展欧几里德)

    题目链接 AC了.经典问题,a*x+b*y+c = 0整数点,有些忘记了扩展欧几里德,复习一下. #include <cstdio> #include <iostream> # ...

  6. css比较容易搞混的三个选择器

    直接后代选择器:> .grid>input[type="button"] 所有后代选择器:空格 .grid input[type="button"] ...

  7. thinkphp遗留问题

    $data = array( 'username' => I('username','','htmlspecialchars'), 'content' => I('content'), ' ...

  8. jsonkit mrc于arc混编

  9. iOS 项目中用到的一些开源库和第三方组件

    iOS 项目中用到的一些 iOS 开源库和第三方组件 分享一下我目前所在公司 iOS 项目中用到的一些 iOS 开源库和第三方组件, 感谢开源, 减少了我们的劳动力, 节约了我们大量的时间, 让我们有 ...

  10. Java_JDK动态代理学习笔记

    昨天被问了个问题,问题的大意是这样的:为什么 Proxy.newProxyInstance(ClassLoader loader, Class<?>[] interfaces, Invoc ...