I create a mini window like an iTunes mini window:

It is dragged and has a background image on it.
Then I subclassed NSWindow and overrides its initWithContentRect:styleMask:backing:defer: and added NSImageView to it:
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { contentRect.size = CGSizeMake(287, 287); self = [super initWithContentRect:contentRect styleMask:aStyle backing:bufferingType defer:flag]; if (self) { [self setMovableByWindowBackground:YES]; [self setOpaque:NO]; [self setBackgroundColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.5]]; NSImageView *imageView = [[NSImageView alloc] initWithFrame:(CGRect){CGPointZero, contentRect.size}]; imageView.image = [NSImage imageNamed:@"MiniWindow.png"]; [self.contentView addSubview:imageView]; } return self; }
But after I add NSImageView to the window contentView, the window will become inaccessible.
How to make the window draggable again?
Best wishes
cocoa macos nswindow
Openthread
source share