我不需要代码,但希望有关如何通过手指触摸在iPhone上绘制平滑线条的参考教程。
当用户绘制第二条线时,如何查找第二条线是否与第一条线相交。
谢谢!
我不需要代码,但希望有关如何通过手指触摸在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];
}
}
你可以从文档中获取相关的类引用。