我知道这可能是重复的,但我想知道选择单元格时更改蓝色突出显示颜色的最佳方法。如何在选择单元格时更改蓝色突出显示颜色
诅咒,我已经尝试过(和它的作品),其包括在变化当小区选择(这样thread),背景色的方式,但我不喜欢这样,我宁愿真的改变这个高光颜色。
任何链接或想法?谢谢。
我知道这可能是重复的,但我想知道选择单元格时更改蓝色突出显示颜色的最佳方法。如何在选择单元格时更改蓝色突出显示颜色
诅咒,我已经尝试过(和它的作品),其包括在变化当小区选择(这样thread),背景色的方式,但我不喜欢这样,我宁愿真的改变这个高光颜色。
任何链接或想法?谢谢。
里面的tableview的
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
创建一个UIImageView,并改变它的背景颜色为你想要的颜色
if (cell == nil) {
UIImageView *bgView = [[UIImageView alloc]initWithFrame:cell.frame];
bgView.backgroundColor = [UIColor greenColor];
cell.selectedBackgroundView = bgView;
}
首先,你必须创建与细胞的大小相同的景色。将背景颜色应用于该视图。然后在cellForRowAtIndexpath委托方法中将该视图设置为您的单元格的选定背景。
[cell setSelectedBackgroundView:yourView];
如果您正在使用笔尖,然后在单元格属性检查器中创建表格视图单元格中,可以看到一个属性“选项”。将其设置为无。
如果乌拉圭回合编程方式创建,然后设置你的细胞作为
yourCell.selectionStyle = UITableViewCellEditingStyleNone;
在这种方法写这些线
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
if (cell == nil)
{
cell.selectedBackgroundView.backgroundColor = [UIColor clearColor];
UIImageView *bgView = [[UIImageView alloc]initWithFrame:cell.frame];
bgView.backgroundColor = [UIColor redColor];
cell.selectedBackgroundView = bgView;
}
您可以将新的UIView分配到细胞与所需的颜色selectedBackgroundView。 斯威夫特3
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "departmentCell", for: indexPath)
let selectedView = UIView(frame: cell.frame)
selectedView.backgroundColor = ColorKit.cellSelectionColor
cell.selectedBackgroundView = selectedView
return cell
}
您可以向TableCell的给selectedBackgrounndView。这是做这件事最正确的方法。 – Divyu
如何创建你的表格视图.. –
蓝色是相对于'selectedBackgroundView'属性的吗? – Lucien