5

I'm trying to create a UIImage with some contents in it. In my app, the user will be able to see an image by tapping on different things, and the parts of the image they change would be based on what they tap. I'm doing this by layering UIImages on top of each other. How would I be able to create a UIImage (for the user to export) that takes the same method, by layering images on top of each other? Thanks :)

Eugene P
  • 554
  • 4
  • 19
  • possible duplicate of [How to create an image from a UIView / UIScrollView](http://stackoverflow.com/questions/2500915/how-to-create-an-image-from-a-uiview-uiscrollview) – Wain Dec 17 '13 at 13:11

1 Answers1

12

This will help you

UIImage *image1 = [UIImage imageNamed:@"image1.png"]; 
UIImage *image2 = [UIImage imageNamed:@"image2.png"]; 

CGSize newSize = CGSizeMake(width, height);
UIGraphicsBeginImageContext( newSize );

[image1 drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];

[image2 drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:0.8];
UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102