Skip to content

Instantly share code, notes, and snippets.

@yyyyyyuanfei
Created February 24, 2012 07:39
Show Gist options
  • Select an option

  • Save yyyyyyuanfei/1898776 to your computer and use it in GitHub Desktop.

Select an option

Save yyyyyyuanfei/1898776 to your computer and use it in GitHub Desktop.
drop shadow of text in obj-c
- (void) drawTextInRect:(CGRect)rect {
CGSize myShadowOffset = CGSizeMake(0, 0);
float myColorValues[] = {0, 0, 0, .8};
CGContextRef myContext = UIGraphicsGetCurrentContext();
CGContextSaveGState(myContext);
CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef myColor = CGColorCreate(myColorSpace, myColorValues);
CGContextSetShadowWithColor (myContext, myShadowOffset, 2, myColor);
[super drawTextInRect:rect];
CGColorRelease(myColor);
CGColorSpaceRelease(myColorSpace);
CGContextRestoreGState(myContext);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment