In my application, NSView should have a rounded rectangle and a border, I tried to follow
static CGColorRef CGColorCreateFromNSColor (CGColorSpaceRef colorSpace, NSColor *color) { NSColor *deviceColor = [color colorUsingColorSpaceName: NSDeviceRGBColorSpace]; float components[4]; [deviceColor getRed: &components[0] green: &components[1] blue: &components[2] alpha: &components[3]]; return CGColorCreate (colorSpace, components); }
and the following lines of code are added to InitWithframe
[[self layer] setCornerRadius:505]; [[self layer] setBorderWidth:500.0]; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB (); CGColorRef cgColor = CGColorCreateFromNSColor (colorSpace, [NSColor whiteColor]); CGColorSpaceRelease (colorSpace); [[self layer] setBorderColor:cgColor];
but there are no effects at all, is there any other method,
Another approach I could guess is to draw a border in drawRect, but it seems very difficult if anyone can offer me another method
Yours faithfully
Rohan
Ammitg2k12
source share