想实现的效果如下:
后来实现:让美工做了一个左边黄色竖线,右边透明的图片
把最重要的两点记下来吧:
cell.selectedBackgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"left_cell_line.png"]]autorelease];
// cell.selectedBackgroundView =left_cellImgView; //定义一个全局变量,这样就不能每次去alloc了吧
cell.textLabel.highlightedTextColor=[UIColor yellowColor];
转载自:http://www.cnblogs.com/chen111/archive/2012/08/25/2655795.html
1.系统默认的颜色设置
1 //无色 2 cell.selectionStyle=UITableViewCellSelectionStyleNone; 3 //蓝色,也就是系统默认的颜色 4 cell.selectionStyle=UITableViewCellSelectionStyleBlue; 5 //灰色 6 cell.selectionStyle=UITableViewCellSelectionStyleGrap;
2.自定义UITableViewCell选中后的背景颜色和背景图片
1 UIColor* color=[[UIColor alloc]initWithRed:0.0 green:0.0 blue:0.0 alpha:1];//通过RGB来定义颜色 2 cell.selectedBackgroundView=[[UIView alloc]initWithFrame:cell.frame]autorelease]; 3 cell.selectedBackgroundView.backgroundColor=[UIColor ***]或color; 4 5 自定义选中后的背景图片 6 cell.selectedBackgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"123.png"]]autorelease]; 7 设置UITableViewCell中的字体颜色时用 8 cell.textLabel.highlightedTextColor=[UIColor **color];
博客介绍了如何自定义UITableViewCell选中时的颜色和背景图片,通过设置selectedBackgroundView为一个UIImageView并加载自定义图片,以及修改textLabel的highlightedTextColor为黄色来实现效果。

5171

被折叠的 条评论
为什么被折叠?



