BlobURLOfUIImage
Create NSURL from UIImage.
Installation
pod 'BlobURLOfUIImage'
Usage
BlobURLOfUIImage *blobURLOfUIImage = [[BlobURLOfUIImage alloc] init];
NSURL *imageBlobURL = [blobURLOfUIImage createUrlForUIImage:[UIImage imageNamed:@"150x150.png"]];
// => image url file:///...
API
- (NSURL *)createUrlForUIImage:(UIImage *) image;
- (NSURL *)temporaryDirectoryURL;
// remove all temporary images form /tmp
- (void)cleanupTemporary;
Use case
Run example.
Want to embed UIImage to HTML's <img>
tag.
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"index" ofType:@"html"];
NSString *contentHTML = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
NSURL *imageBlobURL = [self.blobURLOfUIImage createUrlForUIImage:[UIImage imageNamed:@"150x150.png"]];
NSString *result = [contentHTML stringByReplacingOccurrencesOfString:@"{{img}}" withString:imageBlobURL.path];
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT