Created
February 19, 2015 20:56
-
-
Save loganwright/e4c5cbc28b05a01f6c3a to your computer and use it in GitHub Desktop.
UIImage+Base64
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
| #import <UIKit/UIKit.h> | |
| @interface UIImage (Base64) | |
| - (NSString *)base64EncodedVersion; | |
| + (UIImage *)imageWithBase64String:(NSString *)base64String; | |
| @end |
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
| #import "UIImage+Base64.h" | |
| @implementation UIImage (Base64) | |
| - (NSString *)base64EncodedVersion | |
| { | |
| NSData *data = UIImagePNGRepresentation(self); | |
| return [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed]; | |
| } | |
| + (UIImage *)imageWithBase64String:(NSString *)base64String | |
| { | |
| NSData *data = [[NSData alloc]initWithBase64EncodedString:base64String options:NSDataBase64DecodingIgnoreUnknownCharacters]; | |
| return [UIImage imageWithData:data]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment