How to display a base64 image within a UIImageView?

You don’t have to encode it. Simply make a NSUrl, it knows the “data:”-url. NSURL *url = [NSURL URLWithString:base64String]; NSData *imageData = [NSData dataWithContentsOfURL:url]; UIImage *ret = [UIImage imageWithData:imageData]; As mentioned in the comments, you have to make sure that you prepend your data with data:image/png;base64, or else your base64 data is useless.

add UIImage in CALayer

This is a general answer for the sake of future viewers. It is based on the question title rather than the details of the original question. How to add a UIImage to a CALayer You can add an image to a view’s layer simply by using its contents property: myView.layer.contents = UIImage(named: “star”)?.cgImage Note that … Read more

Howe to capture UIView top UIView

You can take a screenshot of any view or whole screen of the iPhone app with below method – (UIImage *)captureView { //hide controls if needed CGRect rect = [self.view bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [self.view.layer renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; } And call it like bellow… UIImage *tempImageSave=[self captureView]; and … Read more

UIImage Saving image with file name on the iPhone

Kenny, you had the answer! For illustration I always think code is more helpful. //I do this in the didFinishPickingImage:(UIImage *)img method NSData* imageData = UIImageJPEGRepresentation(img, 1.0); //save to the default 100Apple(Camera Roll) folder. [imageData writeToFile:@”/private/var/mobile/Media/DCIM/100APPLE/customImageFilename.jpg” atomically:NO];

Storing images locally on an iOS device

The simplest way is to save it in the app’s Documents directory and save the path with NSUserDefaults like so: NSData *imageData = UIImagePNGRepresentation(newImage); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *imagePath =[documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@”%@.png”,@”cached”]]; NSLog(@”pre writing to file”); if (![imageData writeToFile:imagePath atomically:NO]) { NSLog(@”Failed to cache image data to … Read more

iOS – UIImageView – how to handle UIImage image orientation

If I understand, what you want to do is disregard the orientation of the UIImage? If so then you could do this: UIImage *originalImage = [… whatever …]; UIImage *imageToDisplay = [UIImage imageWithCGImage:[originalImage CGImage] scale:[originalImage scale] orientation: UIImageOrientationUp]; So you’re creating a new UIImage with the same pixel data as the original (referenced via its … Read more