- (instancetype)initWithFrame:(CGRect)frame{spa
if (self = [super initWithFrame:frame]) {.net
_red = 0;3d
_green = 0.5;orm
_blue = 1.0;blog
}it
return self;margin
}top
- (void)drawTextInRect:(CGRect)rect{vi
CGSize textShadowOffest = CGSizeMake(0, 0);ant
CGFloat textColorValues[] = {_red, _green, _blue, 1.0};
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
CGContextSetShadow(ctx, textShadowOffest, 4);
CGColorSpaceRef textColorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef textColor = CGColorCreate(textColorSpace, textColorValues);
CGContextSetShadowWithColor(ctx, textShadowOffest, 4, textColor);
[super drawTextInRect:rect];
CGColorRelease(textColor);
CGColorSpaceRelease(textColorSpace);
CGContextRestoreGState(ctx);
}
http://my.oschina.net/joanfen/blog/145184