【发布时间】:2011-05-31 11:01:26
【问题描述】:
我不想要任何代码,但我需要有关如何通过手指触摸在 iPhone 上绘制平滑线的参考教程。
当用户绘制第二条线后,我如何才能找到第二条线与第一条线相交。
提前谢谢....
【问题讨论】:
标签: iphone objective-c
我不想要任何代码,但我需要有关如何通过手指触摸在 iPhone 上绘制平滑线的参考教程。
当用户绘制第二条线后,我如何才能找到第二条线与第一条线相交。
提前谢谢....
【问题讨论】:
标签: iphone objective-c
我正在使用这个:
- (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];
}
}
您可以从苹果获得相关的类参考。
【讨论】: