问题描述
|
我不需要任何代码,但是我需要参考指南,内容涉及如何通过手指触摸在iPhone上绘制平滑线。
在绘制第一条线后,当用户绘制第二条线时,如何找到第二条线与第一条线不相交的位置。
提前致谢....
解决方法
我正在使用这个:
- (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];
}
}
您可以从apple获取相关的类参考。