选择单元格时如何更改蓝色突出显示颜色

Luc*_*ien 0 objective-c uitableview ios

我知道它可能是重复的,但我想知道在选择单元格时更改蓝色突出显示颜色的最佳和最快方法.

诅咒,我已经尝试(并且它有效)在选择单元格时改变背景颜色的方式(比如这个线程),但我不喜欢这种方式,我宁愿真正改变这种高亮颜色.

任何链接或想法?谢谢.

man*_*jmv 7

在tableview的内部

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

创建一个uiimageview并将其背景颜色更改为所需的颜色

if (cell == nil) {
    UIImageView *bgView = [[UIImageView alloc]initWithFrame:cell.frame];
    bgView.backgroundColor = [UIColor greenColor];
    cell.selectedBackgroundView = bgView;
}
Run Code Online (Sandbox Code Playgroud)

  • @Lucien应用这个答案.这是完美的. (2认同)