Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9036195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:55:42+00:00 2026-06-16T08:55:42+00:00

In my app i have view where user can draw arrows. It works almost

  • 0

In my app i have view where user can draw arrows.
It works almost perfect.
If i swipe slowly i have nice result.
Image

Bu if i try to swipe faster i got the arrowhead somewhere but not at the very end of line.
image

Sorry, due to my reputation i can’t post images here.

How Can i improve arrowhead line drawing to draw however fast i swipe?

To do this i use next method –

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

mouseSwiped = YES;



UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];

 UIGraphicsBeginImageContext(self.view.frame.size);
   [self.tempDrawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

  CGContextClearRect(UIGraphicsGetCurrentContext(),CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height));

   double slopy, cosy, siny;
   // Arrow size
   double length = 10.0;
   double width = 10.0;

   slopy = atan2((firstPoint.y - lastMovePoint.y), (firstPoint.x - lastMovePoint.x));
   cosy = cos(slopy);
   siny = sin(slopy);


   CGContextMoveToPoint(UIGraphicsGetCurrentContext(), firstPoint.x, firstPoint.y);
   CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
        //here is the tough part - actually drawing the arrows
   //a total of 6 lines drawn to make the arrow shape

   CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastMovePoint.x, lastMovePoint.y);

   CGContextAddLineToPoint(UIGraphicsGetCurrentContext(),
                           lastMovePoint.x +  (length * cosy - ( width / 2.0 * siny )),
                           lastMovePoint.y +  (length * siny + ( width / 2.0 * cosy )) );
   CGContextAddLineToPoint(UIGraphicsGetCurrentContext(),
                           lastMovePoint.x +  (length * cosy + width / 2.0 * siny),
                           lastMovePoint.y -  (width / 2.0 * cosy - length * siny) );
   CGContextClosePath(UIGraphicsGetCurrentContext());

   CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
   CGContextSetLineWidth(UIGraphicsGetCurrentContext(), brush );
   CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0);
   CGContextSetBlendMode(UIGraphicsGetCurrentContext(),kCGBlendModeNormal);

   CGContextStrokePath(UIGraphicsGetCurrentContext());
   self.tempDrawImage.image = UIGraphicsGetImageFromCurrentImageContext();
   [self.tempDrawImage setAlpha:opacity];
   UIGraphicsEndImageContext();

   lastMovePoint = currentPoint;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:55:43+00:00Added an answer on June 16, 2026 at 8:55 am

    From my experience when drawing with core graphics, when swiping fast over a view, the distance between the points every time touchesMoved: gets called is larger, and I see that you are using a lastMovePoint which can be further than you’d like, giving you unwanted results. This does not happen when moving slowly and the distance between each point is minimal (sometimes even less than 1 point)

    I suggest working only with the firstPoint and currentPoint, calculate the angle and draw the arrow using only that, because, when it comes to it, to draw a line you only need the first and last point, it doesn’t matter where the user touched before 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my app I have a bit where the user can take a photo
I want to have a view in my app that allows the user to
I have finger painting stuff on one view of my app. When the user
I have an app where a user can enter a project into a database.
in my app i have three editText where the user can place a number.then.when
In my app I need to draw a circle and user can drag it
In my iPhone app I have a settings page where a user can enter
I have an app where a user can enter projects into a database. One
I have an app where a user can enter a project into a database.
I've got a part in my app where the user can view some notes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.