Ios 自定义uitableviewcell高亮显示颜色
我正在设置自定义uitableviewcell选择颜色,如下所示:Ios 自定义uitableviewcell高亮显示颜色,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我正在设置自定义uitableviewcell选择颜色,如下所示: cell.contentView.backgroundColor = [[UIColor alloc]initWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1]; UIView *bgColorView = [[UIView alloc] init]; bgColorView.backgroundColor = [UIColor
cell.contentView.backgroundColor = [[UIColor alloc]initWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1];
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor colorWithRed:(240.0/255.0) green:(240.0/255.0) blue:(240.0/255.0) alpha:1.0];
bgColorView.layer.masksToBounds = YES;
cell.selectedBackgroundView = bgColorView;
这非常有效,只是因为我的UITableViewCell的常规背景色不是白色,当高光出现后淡出变为白色,然后我的背景色变为白色,而不是淡出为背景色。有人知道如何解决这个问题吗?与其设置
contentView
的背景色,不如设置backgroundView
UIView *bgView = [[UIView alloc] init];
bgView.backgroundColor = [[UIColor alloc]initWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1];
cell.backgroundView = bgView;
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor colorWithRed:(240.0/255.0) green:(240.0/255.0) blue:(240.0/255.0) alpha:1.0];
bgColorView.layer.masksToBounds = YES;
cell.selectedBackgroundView = bgColorView;
从
tableview:cellFor…
返回后,背景由tableview设置。因此,单元格背景定制应该在中处理,向我们展示整个cellForRowAtIndexPath方法