私ができたことは、NSWindow のカスタム サブクラスを提供することです。
@implementation ELGRoundWindow
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
{
self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag];
if ( self )
{
[self setStyleMask:NSBorderlessWindowMask];
[self setOpaque:NO];
[self setBackgroundColor:[NSColor clearColor]];
}
return self;
}
- (void) setContentView:(NSView *)aView
{
aView.wantsLayer = YES;
aView.layer.frame = aView.frame;
aView.layer.cornerRadius = 20.0;
aView.layer.masksToBounds = YES;
[super setContentView:aView];
}
@end
そして IB で、コンテンツ ビューのクラスを ELGRoundView に変更しました。
@implementation ELGRoundView
- (void)drawRect:(NSRect)dirtyRect
{
[[NSColor colorWithCalibratedRed:0.0 green:0.5 blue:1 alpha:1] set];
NSRectFill(dirtyRect);
}
@end
次のように、コンテンツ ビューに別の正方形のサブビューを配置しました。
@implementation ELGSquareView
- (void)drawRect:(NSRect)dirtyRect
{
[[NSColor colorWithCalibratedRed:0.0 green:0 blue:1 alpha:1] set];
NSRectFill(dirtyRect);
}
@end
私は結局:
