绘制两点之间的直线我有我的UIView两个方形的图像。一旦我将手指从一个图像拖到另一个图像上,我想在它们之间绘制一条直线。通过拖动IOS
我处理了touchesMoved
方法来检查我的touchLocation何时到达任一图像的框架。所以我在的开始绘制和两个点之间处理逻辑部分。
我只是无法弄清楚如何,使用(void)drawRect:(CGRect)rect
做。首先,我在drawRect中添加了一个NSlog,并且我编写了代码在两行之间绘制一条线,即使这没有发生。
我检查这个question too,但我想继续拖累和绘制多个点之间的线路。
- (void)drawRect:(CGRect)rect
{
NSLog(@"Draw Rect Entered");
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextSetStrokeColorWithColor(context, [[UIColor blackColor]CGColor]);
CGContextSetLineWidth(context, 1.0);
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, 20, 20);
CGContextStrokePath(context);
}
是'-drawRect:'绝对被称为 - 你叫'地方-setNeedsDisplay'? 。 – 2013-03-08 14:25:14
drawRect中没有得到called..no我“米不是要求-setneedsDisplay我在哪里都叫它 – 2013-03-08 14:26:51