Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.