下面是我的代码:
cell.accessoryType = UITableViewCellAccessoryType.Checkmark但当我运行应用程序时,我看不到复选标记。
然后我将背景颜色设置为黑色,我可以看到一个白色的复选标记。
如何将复选标记的颜色更改为其他颜色,如蓝色?
发布于 2015-06-11 01:14:58
是的,你能做到的。
只需设置单元的tintColor即可。
cell.tintColor = UIColor.whiteColor()
cell.accessoryType = UITableViewCellAccessoryType.CheckmarkSwift 3
let aCell = tableView.dequeueReusableCell(withIdentifier: "Cell")!
aCell.tintColor = UIColor.red
aCell.accessoryType = .checkmark
return aCell

您也可以在属性检查器中执行此操作

发布于 2017-01-10 15:16:39
只需从属性检查器或通过如下所示的代码设置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
}@HenriqueGüttlerMorbin检查这个希望它会为你工作。
发布于 2019-09-02 00:31:10
您还可以在您的单元格类( UITableViewCell类的子类化)中设置颜色。如果希望对表视图的所有行应用相同的颜色,请在awakeFromNib方法中设置tintColor属性。如下所示:
override func awakeFromNib() {
super.awakeFromNib()
accessoryType = .checkmark
tintColor = .red
}当然,如果在视图控制器的cellForRowAt方法中设置颜色,则可以使用indexPath参数根据所显示的行来设置不同的颜色。
https://stackoverflow.com/questions/30762863
复制相似问题