How to combine two images into one image object?
How do I combine two images?
I mean I have two images, one small and the other large. I want to add a small image to a large one at a certain point and I need to get it UIImage
as a result.
I've tried CGCreateImageFromMask
but this makes the small image completely covered by the large image.
You want to use UIGraphicsBeginImageContext()
to create CGContextRef
, then use UIGraphicsGetCurrentContext()
to get a link to it.
Now draw the current images in context. When you're done, use UIGraphicsGetImageFromCurrentContext()
to create UIImage
from this context and UIGraphicsEndImageContext()
to clean up.
source to share