のサブクラスを作成します NSImageView
そしてオーバーライド mouseDownCanMoveWindow
方法:
- (BOOL)mouseDownCanMoveWindow
{
return YES;
}
質問
iTunesミニウィンドウのようなミニウィンドウを作成しています:
ドラッグ可能で、背景画像があります。
次に、aを作成しました NSWindow
のサブクラスとオーバーライド initWithContentRect:styleMask:backing:defer:
メソッド、および追加しました NSImageView
それに:
- (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;
}
しかし、私が追加した後 NSImageView
WindowのContentViewに、ウィンドウは説明できません。
ウィンドウを再びドラッグ可能にする方法は?
よろしくお願いします
解決
のサブクラスを作成します NSImageView
そしてオーバーライド mouseDownCanMoveWindow
方法:
- (BOOL)mouseDownCanMoveWindow
{
return YES;
}