gpt4 book ai didi

iphone - 如何在 iPhone 中使用鼠标签名

转载 作者:行者123 更新时间:2023-12-03 20:46:37 28 4
gpt4 key购买 nike

我必须制作一个应用程序,在交易完成之前需要数字签名进行身份验证。

现在我不知道如何实现它。我的要求是:-

  1. 我可以通过滑动手指进行签名的屏幕。

现在谁能告诉我如何制作这样一个屏幕,我可以用手指签名,并且可以在背面捕获它。

最佳答案

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{

mouseSwiped = NO;
UITouch *touch = [touches anyObject];

if ([touch tapCount] == 2) {
drawImage.image = nil;
return;
}

if ((lastPoint.x<17 && lastPoint.y < 116) || (lastPoint.x>287 && lastPoint.y >159))
NSLog(@"Outside");
else
{
lastPoint = [touch locationInView:vw];
// lastPoint.y -= 20;
}

}


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
mouseSwiped = YES;

UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:vw];

if ((currentPoint.x<17 && currentPoint.y < 116) || (currentPoint.x>287 && currentPoint.y >159))
NSLog(@"Outside");
else
{
UIGraphicsBeginImageContext(vw.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, vw.frame.size.width, vw.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

lastPoint = currentPoint;

mouseMoved++;

if (mouseMoved == 10) {
mouseMoved = 0;
}
}

}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:vw];


if ([touch tapCount] == 2) {
drawImage.image = nil;
return;
}

if ((currentPoint.x<20 && currentPoint.y < 199) || (currentPoint.x>743 && currentPoint.y >425))
NSLog(@"Outside");
else
{
if(!mouseSwiped)
{
UIGraphicsBeginImageContext(vw.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, vw.frame.size.width, vw.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
}
}

关于iphone - 如何在 iPhone 中使用鼠标签名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5634696/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com