自定义 UITableViewCell 选中时颜色的设置

1.系统默认的有三种颜色

cell.selectionStyle = UITableViewCellSelectionStyleNone;

cell.selectionStyle = UITableViewCellSelectionStyleBlue;

cell.selectionStyle = UITableViewCellSelectionStyleGray;

cell.selectionStyle = UITableViewCellSelectionStyleDefault;

 

2.改变选中的cell的背景色

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

cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame]; 
cell.selectedBackgroundView.backgroundColor = [UIColor color];

 

3.自定义UITableViewCell选中时背景图片

cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] ; 
cell.textLabel.highlightedTextColor = [UIColor xxxcolor];

 [cell.textLabel setTextColor:color];

 

4.设置tableViewCell间的分割线的颜色

[theTableView setSeparatorColor:[UIColor xxColor]];

 

你可能感兴趣的:(移动端)