서브 클래스를 만듭니다 NSImageView
그리고 무시합니다 mouseDownCanMoveWindow
방법:
- (BOOL)mouseDownCanMoveWindow
{
return YES;
}
문제
iTunes Mini 창과 같은 미니 창을 만들고 있습니다.
드래그 가능하고 배경 이미지가 있습니다.
그런 다음 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;
}