Combine one UIImage onto of another UIImage :
Combining two images, especially useful, if the overlay image has an alpha value:
#import <Foundation/Foundation.h>
@interface UIImage (combine) - (UIImage*)overlayWith:(UIImage*)overlayImage; @end
And the implementation file.#import "UIImage+Category.h"
@implementation UIImage (combine) - (UIImage*)overlayWith:(UIImage*)overlayImage { UIGraphicsBeginImageContext(self.size); [self drawAtPoint:CGPointZero]; [overlayImage drawAtPoint:CGPointZero]; UIImage *combinedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return combinedImage; }
@end
Above i have declare the UIImage+Category Lib files for the UIImage.
You can see the below sample Example for calling the method for combining
the one image to another and set both images to one images.
You can combine multiple images using this methods.:
the one image to another and set both images to one images.
You can combine multiple images using this methods.:
#import "ViewController.h"
#import "UIImage+Overlay.h"
- (void)viewDidLoad
{
[super viewDidLoad];
self.theImageView.image = [self mergingImage];
}
-(UIImage *)mergingImage {
UIImage *background = [UIImage imageNamed:@"background.png"];
UIImage *audiImage = [UIImage imageNamed:@"audi.png"];
UIImage *combineImage = [background overlayWith:audiImage];
return combineImage;
}
You can Download Transparent images from Here : images.zip
Output of the Project :
audi.png |
Background.png |
+
Combine image |
No comments:
Post a Comment