手写板签字php,手写板,签字版
1.建一个view
.h文件复制以下代码
/**
* 画布
*/
@interface SKGraphicView : UIView
{
CGPoint _start;
CGPoint _move;
CGMutablePathRef _path;
NSMutableArray *_pathArray;
CGFloat _lineWidth;
UIColor *_color;
}
@property (nonatomic,assign)CGFloat lineWidth;/**< 线宽 */
@property (nonatomic,strong)UIColor *color;/**< 线的颜色 */
@property (nonatomic,strong)NSMutableArray *pathArray;
-(UIImage*)getDrawingImg;
2 .m文件
复制以下代码
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
_move = CGPointMake(0, 0);
_start = CGPointMake(0, 0);
_lineWidth = 2;
_color = [UIColor redColor];
_pathArray = [NSMutableArray array];
//创建保存功能
UIButton *but = [UIButton buttonWithType:UIButtonTypeSystem];
but.frame = CGRectMake(0, self.bounds.size.height-60, 100, 60);
[but setTitle:@"保存至相册" forState:UIControlStateNormal];
[but addTarget:self action:@selector(savePhoto) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:but];
UIButton *undoBtn = [UIButton buttonWithType:UIButtonTypeSystem];
undoBtn.frame = CGRectMake(110, self.bounds.size.height-60, 100, 60);
[undoBtn setTitle:@"撤销" forState:UIControlStateNormal];
[undoBtn addTarget:self action:@selector(undoBtnEvent) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:undoBtn];
UIButton *clearBtn = [UIButton buttonWithType:UIButtonTypeSystem];
clearBtn.frame = CGRectMake(220, self.bounds.size.height-60, 100, 60);
[clearBtn setTitle:@"清除" forState:UIControlStateNormal];
[clearBtn addTarget:self action:@selector(clearBtnEvent) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:clearBtn];
}
return self;
}
- (void)drawRect:(CGRect)rect {
// 获取图形上下文
CGContextRef context = UIGraphicsGetCurrentContext();
[self drawPicture:context]; //画图
}
- (void)drawPicture:(CGContextRef)context {
for (NSArray * attribute in _pathArray) {
//将路径添加到上下文中
CGPathRef pathRef = (__bridge CGPathRef)(attribute[0]);
CGContextAddPath(context, pathRef);
//设置上下文属性
[attribute[1] setStroke];
CGContextSetLineWidth(context, [attribute[2] floatValue]);
//绘制线条
CGContextDrawPath(context, kCGPathStroke);
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
_path = CGPathCreateMutable(); //创建路径
NSArray *attributeArry = @[(__bridge id)(_path),_color,[NSNumber numberWithFloat:_lineWidth]];
[_pathArray addObject:attributeArry]; //路径及属性数组数组
_start = [touch locationInView:self]; //起始点
CGPathMoveToPoint(_path, NULL,_start.x, _start.y);
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
// 释放路径
CGPathRelease(_path);
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
_move = [touch locationInView:self];
//将点添加到路径上
CGPathAddLineToPoint(_path, NULL, _move.x, _move.y);
[self setNeedsDisplay];
}
#pragma mark --点击事件--
- (void)savePhoto {
if (_pathArray.count) {
UIGraphicsBeginImageContext(self.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
UIRectClip(CGRectMake(0, 0, self.frame.size.width, self.frame.size.height));
[self.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(image, self, nil, NULL);
}
else{
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"alert" message:@"请您先绘制图形" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
}
}
-(UIImage *)getDrawingImg{
if (_pathArray.count) {
UIGraphicsBeginImageContext(self.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
UIRectClip(CGRectMake(0, 0, self.frame.size.width, self.frame.size.height));
[self.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
return image;
}
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"alert" message:@"请您先绘制图形" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
return nil;
}
-(void)undoBtnEvent
{
[_pathArray removeLastObject];
[self setNeedsDisplay];
}
-(void)clearBtnEvent
{
[_pathArray removeAllObjects];
[self setNeedsDisplay];
}
3在控制器中包含你建立的那个view
调用以下代码就OK 了
SKGraphicView *view = [[SKGraphicView alloc] initWithFrame:CGRectMake(0, 130, kwidth, [UIScreen mainScreen].bounds.size.height - 130)];
view.backgroundColor = [UIColor whiteColor];
view.color = [UIColor blackColor];
view.lineWidth = 10;
[self.view addSubview:view];
4. 大功告成
手写板签字php,手写板,签字版相关推荐
- 不要签字!不要签字!不要签字!最近违法裁员猖獗,这里单独给大家一些应对参考!...
随着裁员潮来袭,许多公司出现了违法裁员现象,处于弱势的打工人在面临违法裁员时常常会不知所措,导致自己的合法权益被侵害. 一位好心网友给大家提供了一些应对措施: 1.按照劳动法,可以选择继续履行劳动合同 ...
- 老年用计算机手写板,什么样的手写板才适合老年朋友使用【详解】
不知不觉,中秋节和国庆节即将来啦!双节将至,想必你也计划好了回家看看父母,跟家人聚聚吧?回家总不能两手空空,惯常的水果月饼是少不了,有没有一些特别的心意给爸妈呢?小兔有个好建议,不放送个电脑写字板吧! ...
- 老年用计算机手写板,什么样的手写板才适合老年朋友使用
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 电脑手写板是采用手写字的方式向电脑中输入文字,符合中国人写汉字的习惯,很容易上手.现如今,使用电脑手写板写字输入文字,也已为很多年轻人和初次接触电脑的孩子 ...
- 友基s400手写板怎么安装_电脑手写板安装步骤 手写板怎么用
电脑手写板就像手机的触笔,无论是书写还是娱乐,只要轻轻一点就可以了,用起来十分方便,所以你知道为什么电脑手写板卖得这么火了吧!那么,到底手写板怎么用呢?下面随小编一起看看手写板怎么用吧. 一.正确安装 ...
- 京东裁员杀红眼了!说要给n+1,员工签字后,公司又反悔了!
前面我们刚写了京喜裁员,如今又有京东员工爆料京东裁员杀红了眼,谈话时说要给n+1,字都签了,又反悔不想给了! 该员工感叹:去年做的最错的决定就是选择了京东offer,所谓的大厂稳定就是个伪命题! 网友 ...
- 用手写板向计算机输入汉字是什么技术,使用手写板输入文字的简单介绍
键盘是一种重要的输入设备,目前出现了几百种计算机汉字输入法,对于较熟练操作计算机的人来说汉字输入已不再是什么问题,但是对于一些想要用计算机,可又是刚刚接触计算机的人,比如说年龄比较大的人和很多的小学生 ...
- 合同法律风险管理 合同签字后果
合同法律风险管理(十四) 学习合同法律风险管理过程中的心得体会以及知识点的整理,方便我自己查找,也希望可以和大家一起交流. 本节涉及法律: <中华人民共和国合同法> -- 合同签字后果 - ...
- 计算机网络笔记手写板,电脑手写板怎么使用?莫慌!手把手教学来了
有些朋友真的很懒,烂到连打字都觉得累,这时候就可以使用手写笔了,那么电脑手写板怎么使用呢?别着急,今天小编就来说说电脑手写板的使用方法.希望对大家有帮助. 手写板是电脑的输入设备之一,我们可以将需要输 ...
- 友基s400手写板怎么安装_电脑手写板怎么安装 轻松学会安装手写板【图文】
很多人买了手写板拿到手,却苦恼于自己是电脑小白而不会安装手写板或者是电脑手写板安装不成功.电脑手写板怎么安装?下面我们一起来学习下怎么安装电脑手写板. 电脑手写板怎么安装 1.把手写板的驱动盘放进光驱 ...
最新文章
- 想转行学软件测试要注意哪些问题
- 植树节,程序员要爬哪些“树”?
- pycharm add configuration怎么配置_python从入门到入土 | 环境配置(二)
- 100个短缺职业排行榜出炉 找工作,这些职业最缺人
- oracle的cv函数,cv_wait 和 cv_timedwait 函数
- 程序直接控制I/O方式
- hdu (欧拉函数+容斥原理) GCD
- PyTorch的六个学习率调整
- 数据链路层差错控制——奇偶校验码、循环冗余码和汉明码(海明码)
- [Mvp.Blazor] 集成Ids4,实现统一授权认证
- c语言字符数组与字符串的使用详解
- 热烈庆祝个人博客突破1万人!
- 深度学习2.0-45.GAN实战
- 【ICLR 2018】模型集成的TRPO算法【附代码】
- Linux之旅(1): diff, patch和quilt (下)
- JavaWeb开发之网站实现文件上传功能
- 华为静态路由配置实例
- 'javac'不是内部或外部命令,也不是可运行的程序或批处理文件.
- 线程池之ForkJoinPool
- html页面上使用vlc,在HTML页面上嵌入VLC插件
热门文章
- python制作图像数据集_详细图像数据集增强原理的python代码
- 【干货】Python爬虫/文本处理/科学计算/机器学习/数据挖掘兵器谱
- linux nfs root无权限,nfs root 无权限_如何允许root用户访问NFS?
- Nature综述:大脑中的音乐
- C语言 vs要安装什么_水电安装装修知识|水电安装要注意什么?
- LeetCode 面试题 峰与谷
- 对于无线传感网的初步认识
- 我是怎么利用微信月收入三万以上的!(绝对的干货来袭!)
- CCF 模拟题,公共钥匙盒
- 入侵你Linux服务器的一万种玩法...