如何在 iPhone 中使用鼠标签名

发布于 2024-10-31 22:18:12 字数 159 浏览 0 评论 0原文

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

现在我不知道如何实施同样的事情。我的要求是:-

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

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

I have to make an application where i need digital signature for authentication before a transaction completes.

Now i do not know how to implement the same. My requirements are:-

  1. A screen where i can sign by swyping my fingers .

Now can anyone please tell me how to do make such a screen where i can sign using my fingers and it can be captured at the back.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隔岸观火 2024-11-07 22:18:12
- (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();
        }
    }
}
- (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();
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文