Hi
I have 2 images.. How can i overlap them so i can get 1 UIImage? Setting the position of image 2 inside image 1 at X, Y
Thanks!
Hi
I have 2 images.. How can i overlap them so i can get 1 UIImage? Setting the position of image 2 inside image 1 at X, Y
Thanks!
Why don't you just have a UIView and put the two images into that as subviews?
UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myimage.png"]];
UIView *imagesView = [[UIView alloc] initWithFrame:image.frame];
[imagesView addSubview:image];
UIImageView *imageToOverlay = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myimagetooverlay.png"]];
[imageToOverlay setCenter:CGPointMake(10,10)];
[imagesView addSubview:imageToOverlay];
[self.view addSubview:imagesView];
Zapacila, have you found an answer to your question? You could do it like this:
#define imageWidth 40
#define imageHeight 60
UIImage *image1 = [UIImage imageNamed:@"firstimage.png"];
UIImage *image2 = [UIImage imageNamed: @"secondimage.png"];
CGSize itemSize = CGSizeMake(imageWidth, imageHeight);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[image1 drawInRect:imageRect];
[image2 drawInRect:imageRect];
UIImage *overlappedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
The UIImage overlappedImage is a new image which contains the initial ones, overlapped. To be honest, I don't know if this is the best method to achieve this result, but I know it definitely works.
If in the meantime you found a more efficient solution, let me know!