Skip to content

Instantly share code, notes, and snippets.

@jwilling
Created April 3, 2012 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwilling/2292277 to your computer and use it in GitHub Desktop.
Save jwilling/2292277 to your computer and use it in GitHub Desktop.
Drawing with shadow offset
- (void)drawInRect:(CGRect)rect {
CGSize shadowOffset = CGSizeMake(0, -1);
float colorValues[] = {0, 0, 0, .9};
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
CGContextSetShadow (ctx, shadowOffset, 1);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef color = CGColorCreate(colorSpace, colorValues);
CGContextSetShadowWithColor (ctx, shadowOffset, 1, color);
[super drawTextInRect:rect];
CGColorRelease(color);
CGColorSpaceRelease(colorSpace);
CGContextRestoreGState(ctx);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment