我正在尝试创建一个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) 我正在创建一个应用程序,但我不想要标题栏:
如果标题一直保持不变,显示它是否有意义?例如,如果一个应用程序没有显示文档的名称或它打开的任何其他资产的名称,并且在其他控件的顶部有足够的空间供您移动窗口时抓住,标题是否有多大用处?
问题是:我该怎么做?我试过使用,[mainWindow setStyleMask:NSBorderlessWindowMask];但我不能让它有圆角。我真的不知道如何制作圆角。除此之外,我不能让它有一个调整大小的控件。如果我使用[mainWindow setStyleMask:NSBorderlessWindowMask | NSResizableWindowMask];它就不再是无边界的了。谁能帮我?谢谢。