Skip to content

Instantly share code, notes, and snippets.

@ktakayama
Created December 25, 2009 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ktakayama/263592 to your computer and use it in GitHub Desktop.
Save ktakayama/263592 to your computer and use it in GitHub Desktop.
@interface UIImage (shadow)
+ (UIImage *) imageWithContentsOfFile:(NSString *)path withShadow:(BOOL)shadow;
@end
@implementation UIImage (shadow)
+ (UIImage *) imageWithContentsOfFile:(NSString *)path withShadow:(BOOL)shadow {
UIImage *image = [UIImage imageWithContentsOfFile:path];
if(!shadow) return image;
UIGraphicsBeginImageContext(CGSizeMake(image.size.width + 12, image.size.height + 12));
CGContextSetShadow(UIGraphicsGetCurrentContext(), CGSizeMake(6.0f, -6.0f), 6.0f);
[image drawAtPoint:CGPointZero];
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment