Minimize / miniaturize cocoa NSWindow without titlebar

本秂侑毒 提交于 2019-12-06 02:46:46

You have to keep the original "traffic light" buttons around and hide them manually.

Here's how I've configured the window:

self.titleVisibility = NSWindowTitleHidden;
self.titlebarAppearsTransparent = YES;
self.movableByWindowBackground = YES;

And here's how I've hidden the traffic lights:

for (id subview in self.contentView.superview.subviews) {
    if ([subview isKindOfClass:NSClassFromString(@"NSTitlebarContainerView")]) {
        NSView *titlebarView = [subview subviews][0];
        for (id button in titlebarView.subviews) {
            if ([button isKindOfClass:[NSButton class]]) {
                [button setHidden:YES];
            }
        }
    }
}

See sample project here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!