/** 设置 cell 里边的一些属性的值 */
cell.imageView.image = [UIImageimageNamed:@"icon_category_0"];
cell.imageView.highlightedImage = [UIImageimageNamed:@"icon_category_highlighted_0"];
cell.textLabel.highlightedTextColor = [UIColor redColor];
UIImageView *bg = [[UIImageViewalloc]init];
bg.image = [UIImageimageNamed:@"bg_dropdown_leftpart"];
cell.backgroundView = bg;
// - cell.selectionStyle = UITableViewCellSelectionStyleNone;当执行了这句代码, 即使 cell 被选中了,内部的子控件也不会进入高亮状态;
cell.textLabel.highlightedTextColor = [UIColor redColor];
// 设置下边的代码的时候 会覆盖cell.selectionStyle 也就是说 下边的代码的选中状态的优先级高于cell.selectionStyle 但是下边的代码有时候会挡住cell里边的子控件而且有时候默认的 selectionStyle 也会挡住内部的子控件;
UIImageView *selectedBg = [[UIImageViewalloc]init];
selectedBg.image = [UIImageimageNamed:@"bg_dropdown_left_selected"];
cell.selectedBackgroundView = selectedBg;
iOS 自定义cell点击后里面的子控件背景颜色被改变解决办法
1. /**
2. * 重新设置badgeView的背景颜色
3. */
4. - (void)layoutSubviews
5. {
6. [super layoutSubviews];
7. _badgeView.backgroundColor = kRedColor;
8.
9. }
11. }