iOS 8 UITableView 在未选中时淡出复选标记

iOS 8 UITableView Faded out Checkmarks when not selected

当未选择 UITableViewCell 时,是否可以为复选标记提供 alpha 或颜色?默认情况下,iOS 只是在未选择行时没有复选标记。更改复选标记的颜色很简单,但我不确定 iOS 是否支持在未选择 UITableViewCell 时显示淡出复选标记的功能。

我对需要外部图像的解决方案不感兴趣。

您可以在 UITableViewCell 上设置 tintColor 以更改透明度。

cell.accessoryType = UITableViewCellAccessoryType.Checkmark
cell.tintColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.2)

所选单元格 tintColor 的 alpha 设置为 1

if selected[indexPath.row] {
    cell.tintColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1.0)
} else {
    cell.tintColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.2)
}