問題描述
Gaya Jendela Kustom di Kakao (Custom Window Style in Cocoa)
OK, this is what I'm trying to do :
- I have a custom
NSPanel
subclass - I want the
NSPanel
to be borderless (NO title ‑ I'm drawing a titlebar myself) AND resizeable
The thing is that :
- once I set the
styleMask
toNSResizableWindowMask
, the default title bar appears as well. - once I set the
styleMask
toNSBorderlessWindowMask
, the default title bar disappears (that's good), but the window loses its resizing ability.
This is my Code :
‑ (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
{
if ((self = [super initWithContentRect:contentRect styleMask:NSTitledWindowMask backing:bufferingType defer:deferCreation])) {
[self setOpaque:NO];
[self setBackgroundColor:[NSColor clearColor]];
[self setMovableByWindowBackground:YES];
[self setLevel:NSFloatingWindowLevel];
//[self setStyleMask:[self styleMask]&~NSTitledWindowMask];
}
return self;
}
As you may see from the commented‑out code, I've tried using any possible combination of bit operations with the mask so that I combine what I need.
Any ideas??
‑‑‑‑‑
參考解法
方法 1:
Just do them at a time like this
styleMask:NSTitledWindowMask | NSResizableWindowMask
(by Dr.Kameleon、Muke)