uicllectionViewiOS菜鸟食谱

UITableViewCell选中后的颜色设置

2016-03-17  本文已影响1310人  bc3d3e66fba3

1.系统默认的颜色设置

//无色 

cell.selectionStyle=UITableViewCellSelectionStyleNone;

//蓝色,也就是系统默认的颜色cell.selectionStyle=UITableViewCellSelectionStyleBlue;

//灰色

cell.selectionStyle=UITableViewCellSelectionStyleGrap;

2..自定义UITableViewCell选中后的背景颜色和背景图片

UIColor* color=[[UIColor alloc]initWithRed:0.0green:0.0blue:0.0alpha:1];

//通过RGB来定义颜色

cell.selectedBackgroundView=[[UIView alloc]initWithFrame:cell.frame]autorelease];

cell.selectedBackgroundView.backgroundColor=[UIColor  ***]或color;

自定义选中后的背景图片

cell.selectedBackgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"123.png"]]autorelease];

设置UITableViewCell中的字体颜色时用8cell.textLabel.highlightedTextColor=[UIColor **color];

3.定义UITableViewCell的样式

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

accessoryType有如下几种

typedef enum {

UITableViewCellAccessoryNone,

UITableViewCellAccessoryDisclosureIndicator,

UITableViewCellAccessoryDetailDisclosureButton,

UITableViewCellAccessoryCheckmark

} UITableViewCellAccessoryType;

4.隐藏UITableViewCell的分隔线

[chatTableViewsetSeparatorStyle:UITableViewCellSeparatorStyleNone];

UITableViewCellSeparatorStyle

有如下几种

typedef enum {

UITableViewCellSeparatorStyleNone,

UITableViewCellSeparatorStyleSingleLine,

UITableViewCellSeparatorStyleSingleLineEtched

} UITableViewCellSeparatorStyle;

5设置UITableViewCell之间分隔线的颜色

[chatTableView setSeparatorColor:[UIColorblueColor]];

上一篇 下一篇

猜你喜欢

热点阅读