【问题标题】:UITableViewCell editing accessory colorUITableViewCell 编辑附件颜色
【发布时间】:2019-08-02 07:16:15
【问题描述】:

我有一个 UITableView 并在编辑时将多选设置为 true

tableView.allowsMultipleSelectionDuringEditing = true

在单元格配置(cellForRowAtIndexPath)中,我这样做:

            cell.selectionStyle = .default
            cell.accessoryType = .checkmark

所以当 tableView 设置为编辑模式时,我会在左侧看到蓝色复选标记选项。我想更改该配件的默认蓝色。我该怎么做?

【问题讨论】:

  • 看到这个寻求帮助:Change color of accessoryType Swift
  • 试试这个cell.accessoryType = UITableViewCellAccessoryType.checkmark cell.tintColor = UIColor.red
  • cell.tintColor 不能用于编辑复选标记,不知道为什么。

标签: ios swift uitableview uikit


【解决方案1】:

如果您使用情节提要: 在此处更改色调颜色

【讨论】:

    【解决方案2】:

    在您的自定义UITableViewCell 中,像这样在awakeFromNib() 中设置cell's tintColor

    class CustomCell: UITableViewCell {
        override func awakeFromNib() {
            super.awakeFromNib()
            self.tintColor = .red
        }
    }
    

    【讨论】:

    • 这也有效。但是在故事板中这样做也很好。
    【解决方案3】:

    只需根据需要设置单元格的色调即可。它会自动改变配件类型的颜色。

    [cell setTintColor:[UIColor whiteColor]];
    

    【讨论】:

    • 请在设置附件类型后输入此代码,如下所示。 self.tintColor = UIColor.purple self.accessoryType = .checkmark
    猜你喜欢
    • 2016-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多