Reputation: 15147
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....
Upvotes: 6
Views: 5114
Reputation: 543
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.
Upvotes: 11