UITableViewCell的选中时的颜色设置
2016-01-11 16:11
453 查看
1.系统默认的颜色设置
//无色
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//蓝色
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
//灰色
cell.selectionStyle = UITableViewCellSelectionStyleGray;
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的字体的颜色
5、设置cell中字体的颜色
//无色
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、设置cell中字体的颜色
// Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if(0 == indexPath.row) { cell.textLabel.textColor = ...; cell.textLabel.highlightedTextColor = ...; } ... }
相关文章推荐
- Arduino - 休眠模式
- UICollectionView简单使用
- UICollectionView之定制UICollectionViewLayout
- Quartz 2D的坐标系和UIKit的坐标系对比以及相互转换
- 4.7.1. Default Argument Values(默认参数)
- UICollectionView详解
- UICollectionView高级使用示例之CircleLayout
- 实现UILabel高度和宽度的自适应和UITextView的高度自适应
- Failed to run the WC DB work queue associated with解决办法
- iOS UILabel 省略号 不变色 问题处理
- iOS UITableView去掉多余表格线,tableView去掉表头空白、改变导航栏背景色和标题属性
- 一些 UIView 中管理 Subview 常用的方法
- 一个处理程序重复的UIView animateWithDuration
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 一个处理程序重复的UIView animateWithDuration?
- Android开发笔记(四十四)动态UI事件
- unixODBC without the GUI
- 动画 UIView animateWithDuration 使用详解
- Fail to decode request due to: RpcInvocation
- YTU 2900: F-A Simple Question