当用户输入点击指定顶点时,我绘制了一组连接线。我建立一个CGMutablePathRef如何在CGContext CGMutablePathRef上绘制顶点?
- (void)addPointToCGMPR: (CGPoint)p
forNewPolygon: (BOOL)newPoly
{
if (newPoly)
{
CGPathMoveToPoint(cgmpr, NULL, p.x, p.y);
}
else
{
CGPathAddLineToPoint(cgmpr, NULL, p.x, p.y);
}
[self setNeedsDisplay];
}
的drawRect:然后每个点后调用输入,并在上下文CGMutablePathRef添加到CGContext上显示
- (void)drawRect:(CGRect)rect
{
// Set up a context to display
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextAddPath(context, cgmpr);
CGContextSetLineWidth(context, 1);
CGContextStrokePath(context);
// If NOT empty then Close the context so that box comparison can occur later
if (!CGContextIsPathEmpty(context))
{
CGContextClosePath(context);
}
}
我的屏幕为一个在得到线会期待。我的麻烦是,用户选择第一个点后,屏幕上没有任何渲染,并且用户不知道系统是否有第一个选择,直到输入第二个点。我希望系统在输入下一个点之前提供第一个点。我还希望系统渲染以视觉上不同的方式拾取的每个顶点 - 现在我不能获取顶点渲染,只有线。有没有办法让CGContext提供点数?有没有办法指定这些点呈现的样式?谢谢。
感谢您指点我在这些方向,罗布。我需要移动这些点,所以只有这些名字将帮助我找到能够教会我如何设计和管理这部分程序的文档。 +1 – StoneBreaker 2012-04-26 15:22:07