创建一个自定义单元格和覆盖setHighlighted(_ highlighted: Bool, animated: Bool)
改变iamgeView的tintColor:
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
imageView?.tintColor = highlighted ? UIColor.white : UIColor.green
}
然后,当你创建你的,你有UIImageRenderingMode.alwaysTemplate
设置图像:
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = CustomCell()
cell.imageView?.image = UIImage(named: "custom_image")?.withRenderingMode(UIImageRenderingMode.alwaysTemplate)
cell.imageView?.tintColor = UIColor.green
return cell
}
是不是这同样的问题?分别相同的解决方案? https://stackoverflow.com/questions/33249456/nstableviewcell-setselected –
我想这是不一样的情况,是不是? – Ghost108
我不是在MacOS上的专家,但我的猜测是建立NSTableCellView,并通过自己的高亮或其他相关行动didSet手柄选择VAR自定义子类。 –