我正在尝试创建一个NSWindow没有标题栏(NSBorderlessWindowMask)的圆角和阴影,类似于下面的"欢迎使用Xcode"窗口.

我做了一个子类NSWindow:
@implementation FlatWindow
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
{
self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag];
if ( self )
{
[self setOpaque:NO];
[self setBackgroundColor:[NSColor clearColor]];
[self setMovableByWindowBackground:TRUE];
[self setStyleMask:NSBorderlessWindowMask];
[self setHasShadow:YES];
}
return self;
}
- (void) setContentView:(NSView *)aView
{
aView.wantsLayer = YES;
aView.layer.frame = aView.frame;
aView.layer.cornerRadius = 10.0;
aView.layer.masksToBounds = YES;
[super setContentView:aView];
}
@end
Run Code Online (Sandbox Code Playgroud)
还有一个子类NSView:
@implementation ColoredView
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
[[NSColor windowBackgroundColor] set];
NSRectFill(dirtyRect); …Run Code Online (Sandbox Code Playgroud) 有没有办法隐藏NSWindow中的标题栏?我不想完全写一个新的自定义窗口.我不能使用NSBorderlessWindowMask,因为我的窗口上有一个底栏,使用NSBorderlessWindowMask使它消失.我也尝试使用setContentBorderThickness:forEdge:使用NSMaxYEdge并将其设置为0,这也不起作用.
任何帮助表示赞赏
我正在创建一个NSWindow没有标题栏的自定义,并且正在使用NSBorderlessWindowMask它来完全无边框.然而,我遇到的问题是窗户有锋利的边缘.除此之外,没有调整大小控制.
我怎样才能给一个无边框的圆角?
这不是这个问题的重复,因为该问题更多的是删除标题栏,它目前没有答案.