【问题标题】:Drawing a line through finger touch on iPhone在 iPhone 上通过手指触摸画线
【发布时间】:2011-05-31 11:01:26
【问题描述】:

我不想要任何代码,但我需要有关如何通过手指触摸在 iPhone 上绘制平滑线的参考教程。

当用户绘制第二条线后,我如何才能找到第二条线与第一条线相交。

提前谢谢....

【问题讨论】:

    标签: iphone objective-c


    【解决方案1】:

    我正在使用这个:

       - (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];
          }
        }
    

    您可以从苹果获得相关的类参考。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-12
    • 2018-04-29
    • 1970-01-01
    相关资源
    最近更新 更多