如何更改UITableViewCellAccessoryType.Checkmark的颜色?

Ass*_*bin 15 uitableview checkmark swift

这是我的代码:

cell.accessoryType = UITableViewCellAccessoryType.Checkmark
Run Code Online (Sandbox Code Playgroud)

但是当我运行应用程序时,我看不到复选标记.

然后我将背景颜色设置为黑色,我可以看到一个白色的复选标记.

如何将复选标记的颜色更改为蓝色等其他颜色?

Ash*_*kad 33

是的,你可以做到.

只需设置tintColor单元格即可.

cell.tintColor = UIColor.whiteColor()
cell.accessoryType = UITableViewCellAccessoryType.Checkmark
Run Code Online (Sandbox Code Playgroud)

斯威夫特3

let aCell = tableView.dequeueReusableCell(withIdentifier: "Cell")!
aCell.tintColor = UIColor.red
aCell.accessoryType = .checkmark
return aCell
Run Code Online (Sandbox Code Playgroud)

OUTPUT

您也可以从Attributes Inspector中执行此操作

OUTPUT

  • 抱歉@Ashish Kakkad,您的解决方案与复选标记配件配合得很好,但 Apple 在披露配件方面存在问题。没有任何解决方案适用于披露。(A改变了我对你的投票)=] (2认同)

Mai*_*ani 9

只需从Attribute Inspector中设置UITableViewCell的色调颜色,或者通过如下编码设置

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cellIdentifier = "SimpleTableViewCell"
    let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath)

    // just add below lines
    cell.accessoryType = UITableViewCellAccessoryType.checkmark
    cell.tintColor = UIColor.red


    return cell
}
Run Code Online (Sandbox Code Playgroud)

@HenriqueGüttlerMorbin检查这希望它会对你有用.