简体   繁体   中英

Drawing a line through finger touch on iPhone

I do not want any code but I need reference tutorial on how to draw a smooth line on iPhone through finger touch.

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

Thanks in advance....

I am using 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 related class reference from apple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM