Add UIImage on top of another UIImage
ios, objective-c, uiimage
Solution
Try this method:
-(UIImage *)drawImage:(UIImage*)profileImage withBadge:(UIImage *)badge
{
UIGraphicsBeginImageContextWithOptions(profileImage.size, NO, 0.0f);
[profileImage drawInRect:CGRectMake(0, 0, profileImage.size.width, profileImage.size.height)];
[badge drawInRect:CGRectMake(0, profileImage.size.height - badge.size.height, badge.size.width, badge.size.height)];
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultImage;
}
You can use it by:
UIImage *myBadgedImage = [self drawImage:profileImage withBadge:badgeImage];
Problem
i have 2 images: first one is the user personal image, the second one is an icon (badge). i want to add the second uiimage (icon) on the bottom left corner of the first uiimage (user's image) and save them into a new Uiimage. thanks