Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 自定义uitableviewcell高亮显示颜色_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 自定义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

我正在设置自定义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 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方法