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];
을하지만 어떤 둥근 모서리를 설정하지 않습니다! 내가 도대체 뭘 잘못하고있는 겁니까?