iOS开发中,给图片叠加水印,本质上就是对图片进行叠加操作,代码如下:
// 图片叠加
- (UIImage *)addlogoImage:(UIImage *)resizedImage {
UIGraphicsBeginImageContext(resizedImage.size);
[resizedImage drawInRect: CGRectMake(0, 0, resizedImage.size.width, resizedImage.size.height)];
UIImage *maskImage = [UIImageimageNamed:@"new.png"];
[maskImage drawInRect:CGRectMake(0,0,maskImage.size.width,maskImage.size.height)];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage;
}
效果图如下,前三条记录的图片上叠加了“最新”的图片。