添加水印
- 在开发中如果是需要用到很多图片的:比如微博,上传的图片都会在右下角添加水印
- 水印有可能是文字,也有可能是logo
UIImage *image = [UIImage imageNamed:@"bgImage"];
//size:开开启一个多大图片上下文.
//opaque:不透明度 YES:不透明 NO:透明,通常我们一般都弄透明的上下文
//scale:0
//开启跟图片相同的大小上下文.
UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
//把图片给绘制图片上下文.
[image drawAtPoint:CGPointZero];
//绘制文字
//NSString *str = @"sdfadf";
//[str drawAtPoint:CGPointZero withAttributes:nil];
//绘制图片
UIImage *image1 = [UIImage imageNamed:@"icon"];
[image1 drawInRect:CGRectMake(0, 0, 50, 50)];
// 生成图片
UIImage *imageNew = UIGraphicsGetImageFromCurrentImageContext();
//关闭上下文
UIGraphicsEndImageContext();
需要注意的就是开启图片上下文之后,用完了需要自己手动关闭