iOS截屏、给图片添加水印
来源:互联网 发布:多益网络 传送门骑士 编辑:程序博客网 时间:2024/06/14 09:54
//截取视图的内容保存为图片,保存到系统相册
- (IBAction)cutPicAndSaveBtnAction:(id)sender {
//SCALE 为缩放倍数
UIGraphicsBeginImageContextWithOptions(self.bkView.frame.size,NO,SCALE);
CGContextRef context =UIGraphicsGetCurrentContext();
//剪切指定视图的画面
[self.bkView.layerrenderInContext:context];
UIImage * cutImage =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//给图片添加文字水印
NSDictionary *attributedDic =@{NSFontAttributeName:[UIFontsystemFontOfSize:10],NSForegroundColorAttributeName:[UIColorwhiteColor],NSBackgroundColorAttributeName:[UIColorblackColor]};
cutImage = [selfaddWaterTextWithImage:cutImagetext:@"身高:170"textPoint:CGPointMake(0,0)attributedString:attributedDic];
//保存到系统相册
UIImageWriteToSavedPhotosAlbum(cutImage, self, @selector(image:didFinishSavingWithError:contextInfo:),nil);
}
//给图片添加文字水印
- (UIImage *)addWaterTextWithImage:(UIImage *)image text:(NSString *)text textPoint:(CGPoint)point attributedString:(NSDictionary * )attributed{
//1.开启上下文
UIGraphicsBeginImageContextWithOptions(image.size,NO,SCALE);
//2.绘制图片
[image drawInRect:CGRectMake(0,0, image.size.width, image.size.height)];
//添加水印文字
[text drawAtPoint:point withAttributes:attributed];
//3.从上下文中获取新图片
UIImage * newImage =UIGraphicsGetImageFromCurrentImageContext();
//4.关闭图形上下文
UIGraphicsEndImageContext();
//返回图片
return newImage;
}
- iOS截屏、给图片添加水印
- IOS给图片添加文字水印
- iOS给图片添加水印 swift版本
- 给图片添加水印
- 给图片添加水印
- 给图片添加水印
- 给图片添加水印
- 给图片添加水印
- 给图片添加水印
- 给图片添加水印
- 给图片添加水印
- 给图片添加水印
- 给图片添加水印
- 给图片添加图片水印
- 给图片添加水印图片
- iOS 图片添加水印
- ios图片添加水印
- iOS:图片添加水印
- (转载)SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)
- Eclipse配置多个Tomcat服务器
- RandomAccessFile随机读写文件操作类讲解
- 从零开始搭建一个vue.js的脚手架
- 6.4内部类:类作为方法的返回值类型,内部类中使用外部类的引用(或称外部类对象)
- iOS截屏、给图片添加水印
- java的执行过程
- P_002.#!/usr/bin/env python与#!/usr/bin/python的区别
- 9.23 环 2741
- php导出csv数据代码
- 存储过程
- LINTCODE——转换字符串到整数
- erlang位语法常见转换
- 事务的四大特性:原子性,一致性,隔离性,持久性(ACID)