ios 图片水印 (代码)
-(void)viewDidLoad
{
//1.1背景图片
UIImage *bgImage [UIImage imageNamed:@"new"];
CGFloat w = bgImage.size.width;
CGFloat h = bgImage.size.width;
//1.创建图形上下文
UIGraphicsBeginImageContextWithOptions(bgImage.size,NO,0.0);
//1.2.画图
[bgImage drawInRect:CGRectMake(0,0,w,h)];
//2.创建水印图片
UIImage *iconImage = [UIImage imageNamed:@"logo"];
CGFloat iconW = iconImage.size.width * 0.2;
CGFloat iconH = iconImage.size.height *0.2;
CGFloat iconX = w - iconW - 5;
CGFloat iconY = h - iconH - 5;
//2.1画图
[iconImage drawInRect:CGRectMake(iconX,iconY,iconW,iocnH)];
//3.获取当前的图片
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
//4.结束图形
UIGraphicsEndImageContext();
self.imageView.image = newImage;
//5.打印
NSData *data = UIImagePNGRepresentation(newImage);
[data writeToFile:@"/User/apple/DeskTop/new.png" atomically:YES];
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。