Finger line drawing on iPhone

I don’t need any code, but I need a reference tutorial on how to draw a smooth line on iPhone with the touch of a finger.

After drawing the first line, when the user draws the second line, I can find that the second line intersects with the first line or not.

Thanks in advance....

+6
source share
1 answer

I use this:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { self.currentPath = [UIBezierPath bezierPath]; currentPath.lineWidth = 3.0; [currentPath moveToPoint:[touch locationInView:self]]; [paths addObject:self.currentPath]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [self.currentPath addLineToPoint:[touch locationInView:self]]; [self setNeedsDisplay]; } - (void)drawRect:(CGRect)rect { [[UIColor redColor] set]; for (UIBezierPath *path in paths) { [path stroke]; } } 

You can get a link to the associated class from apple.

+11
source

Source: https://habr.com/ru/post/889438/


All Articles