0
コーナーを丸くしたいカスタムのNSViewサブクラスがあります。私は、.mファイルに次のコードを使用します。NSViewサブクラスの丸みのあるコーナーは機能しません
#import "ItemImageSelectionView.h"
@implementation ItemImageSelectionView
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.wantsLayer = YES;
self.layer.frame = self.frame;
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect
{
[[NSColor colorWithCalibratedRed:0.0 green:0.5 blue:1 alpha:1] set];
NSRectFill(dirtyRect);
[self.layer setCornerRadius:5.0];
}
@end
私はビュー、かなりデフォルト初期化する場合は、このコードを使用します。
NSView *imageSelectionView = [[ItemImageSelectionView alloc] initWithFrame:CGRectMake(imageView.frame.origin.x - 2, imageView.frame.origin.y - 2, imageView.frame.size.width + 4, imageView.frame.size.height + 4)];
[self addSubview:imageSelectionView positioned:NSWindowBelow relativeTo:imageView];
をしかし、それはすべての丸みを帯びた角を設定していません!私は間違って何をしていますか?