0

我正在尝试从图像视图的起始点到其目标点画一条线。我的问题是(我猜)如何将超级视图设置为当前绘图上下文(来自图像视图)。有人可以帮忙吗?这是我在图像视图中使用的代码..

    //UIGraphicsPopContext();
CGContextRef context = UIGraphicsGetCurrentContext(); //(problem here????????)
CGContextSetLineWidth(context, 5.0); 
CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor); 

CGContextMoveToPoint(context, startLocationInView.x, startLocationInView.y); 
CGContextAddLineToPoint(context, destinationPositionInView.x, destinationPositionInView.y); 
CGContextStrokePath(context);
4

1 回答 1

0

您不能在其他视图中绘图。您应该做的是扩展视图的边界以覆盖您要绘制的整个区域。

或者,您可以将新的 CALayer 添加到视图的图层以覆盖视图边界之外的区域。

于 2009-09-22T11:01:14.707 回答