使无边框窗口具有更暗更大的阴影
当无边框窗口中的窗口变为活动状态时,如何创建更暗和更大的阴影?
我对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这与窗口的 styleMask 相关。如果将其设置为 NSTitledWindowMask 窗口将获得更大的阴影。
This is tied to the window's styleMask. If it is set to NSTitledWindowMask window will get a larger shadow.
如果这是我的问题,我可能会关闭无边框窗口的阴影属性关闭,然后处理来自
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 myNSWindow
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.
总的来说,我认为达尔马齐奥的观察是正确的,即无论出于何种原因,无边框窗户的阴影不太明显。也许可以向苹果归档雷达。
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.