如何让NSTableView透明?
我想让 NSTableView 透明。
我在这里使用 WindowController 类。
我正在尝试这样做:
- (void)windowDidLoad
{
[super windowDidLoad];
[[self enclosingScrollView] setDrawsBackground: NO];
[[self enclosingScrollView] setBorderType:NSNoBorder];
}
- (BOOL)isOpaque {
return NO;
}
- (void)drawRect:(NSRect)drawRect
{
[super drawRect: drawRect];
}
但是当我编写这段代码时,我在帮助窗口中找不到 enleadingScrollView
。
你可以在这里看到..
有帮助吗?如果我做错了什么,请记住我或纠正我。
谢谢。
I want to make transparent NSTableView.
I am using WindowController class here.
I was trying this:
- (void)windowDidLoad
{
[super windowDidLoad];
[[self enclosingScrollView] setDrawsBackground: NO];
[[self enclosingScrollView] setBorderType:NSNoBorder];
}
- (BOOL)isOpaque {
return NO;
}
- (void)drawRect:(NSRect)drawRect
{
[super drawRect: drawRect];
}
But when i was writing this code i can't found enclosingScrollView
in help window.
you can see here..
Any help?? Please remember me or correct me if i am doing something wrong.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您有一个包含
NSTableView
的NSScrollView
,您可以将滚动视图的drawsBackground
属性设置为NO
,如下所示:If you have an
NSScrollView
enclosing yourNSTableView
, you can set the scroll view'sdrawsBackground
property toNO
like this:得到答案..!!!我刚刚尝试过这个
,它工作正常.. – – Snehal
从有问题的评论中复制,因为它有点被埋藏了......
Got Answer..!!! I just tried this
and its working fine.. – – Snehal
Copied from comment in question, as its a bit buried...
如果您的应用需要显示透明表格视图,请将表格视图的背景颜色设置为清晰,并将封闭的滚动视图设置为不绘制其背景。以下代码片段显示了显示透明表格的一种方法:
Swift:
Objective-C
Apple - 修改表格的视觉属性
If your app needs to display a transparent table view, set the background color of the table view to be clear and set the enclosing scroll view to not draw its background. The following code snippet shows one way to display a transparent table:
Swift:
Objective-C
Apple - Modifying a Table’s Visual Attributes