Adding border and Rounded Rect in the NSView

In my Application , NSView should have rounded rect and border, i tried following

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 in InitWithframe added following lines of Code

    [[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 no effects at all, is there any other method,

Another approach what i could guess is , in drawRect draw border and but it seems very complex, can anyone suggest me any other method

Kind Regards

Rohan

11
задан Amitg2k12 15 February 2011 в 14:37
поделиться