UITableView选中时颜色
2015-08-05 13:48
381 查看
[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>
相关文章推荐
- 【UILabel和UIButton】
- duilib各种布局的作用,相对布局与绝对布局的的意义与用法
- UISlider小结
- uva 11538 Chess Queen
- 自定义segue
- 最近项目中忽略的线程同步,ui更新等问题
- 最近项目中忽略的线程同步,ui更新等问题
- Json转换利器Gson之实例二-Gson注解和GsonBuilder
- Keil4和Protues联调的做法
- LeetCode(95) Unique Binary Search Trees II
- SAPUI5 table formatter
- LeetCode(96) Unique Binary Search Trees
- RequireJs 使用注意点
- 刚进入页面时UIScrollView没有滑动到顶部
- 刚进入页面时UIScrollView没有滑动到顶部
- UIAlertController
- This Android SDK requires Android Developer Toolkit version 23.0.0 or above
- iOS UItableviewcell选择背景颜色和字体颜色设置
- execute、executeUpdate、executeQuery三者的区别(及返回值)(
- UITableView的性能优化10个小技巧