新建 UIImageView *imageView
UIImage *oldImage = [UIImage imageNamed:@"img"];
// 开启上下文
/**
* @param size#> <#size#> description#>新图片的大小
* @param opaque#> <#opaque#> description#> YES不透明 NO透明
* @param scale#> <#scale#> description#>
*/
UIGraphicsBeginImageContextWithOptions(oldImage.size, NO, 0.0);
[oldImage drawAtPoint:CGPointZero];
NSString *textString = @"水印哈哈";
NSDictionary *dict = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0],
NSForegroundColorAttributeName:[UIColor redColor]};
[textString drawAtPoint:CGPointMake(120, 170) withAttributes:dict];
// 获取新的图片
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
// 关闭上下文
UIGraphicsEndPDFContext();
_imageView.image = newImage;
// NSData *data = UIImageJPEGRepresentation(newImage, 0.003);
//
// UIImage *image = [UIImage imageWithData:data];
// _imageView.image = image;
// 把图片转换成png格式的二进制文件
NSData *data = UIImagePNGRepresentation(newImage);
写入保存生成新的图片
[data writeToFile:@"/Users/apple/Desktop/newImage.png" atomically:YES];