在NSTableCellView上设置背景颜色 [英] Set Background colour on NSTableCellView

查看:444
本文介绍了在NSTableCellView上设置背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在NSTableCellView上设置背景颜色,但似乎没有办法做到这一点。

I am trying to set a background colour on an NSTableCellView, but there doesn't seem to be an way to do this.

因此,必须有另一种方式为了实现这一点,我不知道,所以,如果有人可以启发我,我会最感激的!

Therefor there must be another way to achieve this that i am not aware of, so, if anyone could enlighten me i would be most appreciative!

谢谢!

推荐答案

A NSTableCellView NSView ,并且 NSView CALayer CALayer 有一个 backgroundColor 。所以...

A NSTableCellView is a NSView, and a NSView has a CALayer, and a CALayer has a backgroundColor. So...

myTableCellView.wantsLayer = YES;  // make the cell layer-backed
myTableCellView.layer.backgroundColor = [[NSColor redColor] CGColor]; // or whatever color you like

这篇关于在NSTableCellView上设置背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆