Created
December 25, 2009 10:42
-
-
Save ktakayama/263592 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@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