UITableViewCell的选中时的颜色设置
2015-10-12 11:14
579 查看
[cpp] view
plaincopy
1.系统默认的颜色设置
[cpp] viewplaincopy
//无色
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//蓝色
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
//灰色
cell.selectionStyle = UITableViewCellSelectionStyleGray;
2.自定义颜色和背景设置
改变UITableViewCell选中时背景色:UIColor *color = [[UIColoralloc]initWithRed:0.0green:0.0blue:0.0alpha:1];//通过RGB来定义自己的颜色
[html] view
plaincopy
cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];
3自定义UITableViewCell选中时背景
[html] view
plaincopy
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、设置cell中字体的颜色
<span class="com" style="color: rgb(136, 136, 136);">// Customize the appearance of table view cells.</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">(</span><span class="typ" style="color: rgb(0, 0, 136);">UITableViewCell</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">*)</span><span class="pln" style="color: rgb(0, 0, 0);">tableView</span><span class="pun" style="color: rgb(0, 0, 0);">:(</span><span class="typ" style="color: rgb(0, 0, 136);">UITableView</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">*)</span><span class="pln" style="color: rgb(0, 0, 0);">tableView cellForRowAtIndexPath</span><span class="pun" style="color: rgb(0, 0, 0);">:(</span><span class="typ" style="color: rgb(0, 0, 136);">NSIndexPath</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">*)</span><span class="pln" style="color: rgb(0, 0, 0);">indexPath </span><span class="pun" style="color: rgb(0, 0, 0);">{</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(136, 0, 0);">if</span><span class="pun" style="color: rgb(0, 0, 0);">(</span><span class="lit" style="color: rgb(0, 102, 102);">0</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">==</span><span class="pln" style="color: rgb(0, 0, 0);"> indexPath</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">row</span><span class="pun" style="color: rgb(0, 0, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">{</span><span class="pln" style="color: rgb(0, 0, 0);"> cell</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">textLabel</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">textColor </span><span class="pun" style="color: rgb(0, 0, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">...;</span><span class="pln" style="color: rgb(0, 0, 0);"> cell</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">textLabel</span><span class="pun" style="color: rgb(0, 0, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">highlightedTextColor </span><span class="pun" style="color: rgb(0, 0, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">...;</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">}</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">...</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(0, 0, 0);">}</span>
相关文章推荐
- 更改UIPickerView选中框颜色
- Requesting Permissions at Run Time
- 自定义hadoop map/reduce输入文件切割InputFormat 更改输入value的分隔符
- 设置IIS7文件上传的最大大小 maxAllowedContentLength,maxRequestLength
- duilib制作窗体动画效果
- IOS内购 SKProductsRequest请求过程中取消会崩溃
- multiquery image retrieveal
- UIAcceleration
- 开源中国源码学习UI篇(二)之NavigationDrawer+Fragment的使用分析
- UIView的最常用知识
- Android系统文件安全权限检测/system/build.prop修改
- CSS3新增UI样式
- iOS5中UIViewController的新方法
- 解决easyui中重复调用$.messager.progress('close')报错问题
- ZOJ 3911 Prime Query(线段树区间操作)
- 怎么利用jira的Issue style 的可定制性来进行需求和测试用例方面的管理与testLink集成
- C# KeyValuePair 的基本用法及结合泛型的用法
- Requirement Specifications: An Oxymoron
- UIButton 按键
- UITextField 输入框