- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
CGFloat col[] = {1, 1, 1, 1}; //背景色.
float offset = XXX_EdgeWidth;//边宽
self.backgroundColor = XXX_EdgeColor;//边框色.
//圆角
self.layer.cornerRadius = 8.0f;
self.layer.masksToBounds = YES;
//弄出一个圆角的边
CGRect frame2 = frame;
frame2.origin.x = offset;
frame2.origin.y = offset;
frame2.size.width -= offset * 2;
frame2.size.height -= offset * 2;
CALayer *layer2 = [[CALayer alloc] init];
layer2.frame = frame2;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRelease(layer2.backgroundColor = CGColorCreate(colorSpace, col));
CGColorSpaceRelease(colorSpace);
layer2.cornerRadius = self.layer.cornerRadius - offset;
self.layer.masksToBounds = YES;
[self.layer addSublayer:layer2];
[layer2 release];
}
return self;
}