使无边框窗口具有更暗更大的阴影

发布于 2024-12-28 12:35:34 字数 723 浏览 4 评论 0原文

当无边框窗口中的窗口变为活动状态时,如何创建更暗和更大的阴影?

我对 NSWindow 进行了子类化,我的窗口成为主窗口和关键窗口,但这没有帮助......阴影仍然很小。那么也许有人知道如何解决这个问题?我也尝试过使阴影无效,但这也没有帮助..

子类化 NSWindow:

- (id)initWithContentRect:(NSRect)contentRect
            styleMask:(NSUInteger)windowStyle
              backing:(NSBackingStoreType)bufferingType
                defer:(BOOL)flag
{

    self = [super initWithContentRect: contentRect
                  styleMask: NSBorderlessWindowMask 
                    backing: NSBackingStoreBuffered
                      defer: NO];

    if(self)
    {
        [self setHasShadow:YES];

        [self setBackgroundColor:[NSColor clearColor]];
        [self setOpaque:NO];
    }   

return self;
}

How to create darker and larger shadow when window becomes active in borderless window?

I subclassed NSWindow and my window becomes main window and key window but that's not helping.. shadow still small. So maybe someone knows how to fix this? I also tried invalidate shadow, but that didn't help too..

Subclassed NSWindow:

- (id)initWithContentRect:(NSRect)contentRect
            styleMask:(NSUInteger)windowStyle
              backing:(NSBackingStoreType)bufferingType
                defer:(BOOL)flag
{

    self = [super initWithContentRect: contentRect
                  styleMask: NSBorderlessWindowMask 
                    backing: NSBackingStoreBuffered
                      defer: NO];

    if(self)
    {
        [self setHasShadow:YES];

        [self setBackgroundColor:[NSColor clearColor]];
        [self setOpaque:NO];
    }   

return self;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

2025-01-04 12:35:34

这与窗口的 styleMask 相关。如果将其设置为 NSTitledWindowMask 窗口将获得更大的阴影。

This is tied to the window's styleMask. If it is set to NSTitledWindowMask window will get a larger shadow.

清风无影 2025-01-04 12:35:34

如果这是我的问题,我可能会关闭无边框窗口的阴影属性关闭,然后处理来自 display 我的 NSWindow 子类中的函数(确保调用 [super display] 以便各种内容和子类视图调用自己的绘制方法)。

这是一个可能相关的问题以及供您考虑的答案

If this were my problem, I'd probably turn the shadow property off for the borderless window and then handle the shadow drawing from a display function within my NSWindow subclass (making sure to call [super display] so the various content & sub views get their own draw methods called).

Here's a potentially related question with an answer for you to consider.

迷你仙 2025-01-04 12:35:34

总的来说,我认为达尔马齐奥的观察是正确的,即无论出于何种原因,无边框窗户的阴影不太明显。也许可以向苹果归档雷达。

In general I think Dalmazio is correct in his observation that borderless windows have a less pronounced shadow for whatever reason. Maybe file radar with apple.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文