How to combine two images?

H

UIImageView *certImgView;

– (IBAction)combineimages:(id)sender {

UIImage *combinedImg=[self combineTwoImagesFirst:self.certImgView.image andSecond:[UIImage imageNamed:@”1.jpeg”]];

certImgView.image=combinedImg;

}

-(UIImage *)combineTwoImagesFirst:(UIImage *)cardImg andSecond:(UIImage *)faceImg

{

UIImage *bottomImage = faceImg; //background image

UIImage *image       = cardImg; //foreground image

CGSize newSize = CGSizeMake(320, 180);

UIGraphicsBeginImageContext( newSize );

// Use existing opacity as is

[bottomImage drawInRect:CGRectMake(210/2,85/2,205/2,170/2)];

// Apply supplied opacity if applicable

[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:1.0];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return newImage;

}

 

About the author

ankush.ladhane
By ankush.ladhane

Category