創建一個自定義單元格和覆蓋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自定義子類。 –