Created
April 3, 2012 14:08
-
-
Save jwilling/2292277 to your computer and use it in GitHub Desktop.
Drawing with shadow offset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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