转自: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. iOS学习16之OC集合遍历和数组排序

    1.集合遍历 1> 遍历 集合(Collection):OC中提供的容器类:数组,字典,集合. 遍历:对集合中元素依次取出的过称叫做遍历. 三种方式:① for循环遍历: ② NSEnumera ...

  2. BZOJ3072 : [Pa2012]Two Cakes

    考虑DP,设$f[i][j]$表示考虑了$a[1..i]$和$b[1..j]$的最小代价. 若$a[i]==b[j]$,则$f[i][j]=\min(f[i-1][j],f[i][j-1])+1$. ...

  3. Storm-166:Nimbus HA solution based on Zookeeper

    Nimbus HA feature is quite important for our application running on the storm cluster. So, we've bee ...

  4. ACM 阶乘之和

    阶乘之和 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 给你一个非负数整数n,判断n是不是一些数(这些数不允许重复使用,且为正数)的阶乘之和,如9=1!+2!+3! ...

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

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

  6. 属性字符串的replaceCharactersInRange方法

    一,实验: 1> 让 range 的 length 参数为0,以下代码输出属性字符串的结果为12354 NSMutableAttributedString *attrStr = [[NSMuta ...

  7. win7 64位DCOM配置(关于导出excel 配置计算机组件服务)(转)

    http://blog.sina.com.cn/s/blog_9323b3a50101qrxm.html [解决方案1] 1:在服务器上安装office的Excel软件. 2:在"开始&qu ...

  8. C#中WinForm程序退出方法技巧总结(转)

    本文实例总结了C#中WinForm程序退出方法技巧.分享给大家供大家参考.具体分析如下: 在c#中退出WinForm程序包括有很多方法,如:this.Close(); Application.Exit ...

  9. 关于webdriver中弹出框的定位

    对于webdriver中弹出框的定位,需要引入这个包: import org.openqa.selenium.Alert; 具体语句为: Alert alert= driver.switchTo(). ...

  10. Linux_MySql安装

    1.卸载原始mysql-lib sudo rpm -e --nodeps mysql-libs-xx 2.yum安装mysql-server sudo yum -y install mysql -se ...