Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用iOS CoreGraphics绘制十字光标_Ios_Core Graphics - Fatal编程技术网

使用iOS CoreGraphics绘制十字光标

使用iOS CoreGraphics绘制十字光标,ios,core-graphics,Ios,Core Graphics,如何在iOS应用程序中绘制十字光标 - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(context, 1.0, 1.0, 0.0, 0.5); // yellow line CGContextBeginPath(context); CGContextMoveToPoint(context,

如何在iOS应用程序中绘制十字光标

- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBStrokeColor(context, 1.0, 1.0, 0.0, 0.5); // yellow line
    CGContextBeginPath(context);
    CGContextMoveToPoint(context, 40.0, 40.0); //start point

    // Crosshairs go here?!?!?!?
    // What do I fill in?

    CGContextClosePath(context);
    CGContextSetLineWidth(context, 2.0);
    CGContextStrokePath(context); 
    CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 0.0); 
    CGContextFillRect(context, rect); 
}
请参见下面的示例图像


这将有助于你开始了解自己缺少什么。你很接近。添加一个椭圆,您就可以完成了,但正如其他人所建议的,简单快速地查看一下
Quart2d
编程指南或任何
Quart2d
tut都会显示所有这些以及更多内容


你看过《石英2D编程指南》了吗?你所需要的只是两条线和一个圆。是的,我读过,但得到的是形状,不是线。我不得不换个话题,我想我会问的。我想这是不可取的-(嘿,太好了,谢谢你的帮助!我刚刚添加了CGContextStrokeEllipseInRect(上下文,CGRectMake(23.8,14.4,12,12));现在我可以让这些价值观成为相对的。我真的很感谢你的帮助。欢迎你,还有一点友好的建议;在我看来,所有否决票的原因是你问题的措辞。下次试着解释你尝试了什么以及你期望的结果,不要让它听起来像是“做我的功课”问题。人们喜欢在这里提供帮助,但只针对表明研究已经完成的特定问题。编码快乐!
- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetStrokeColorWithColor(context, [UIColor yellowColor].CGColor);
    CGContextSetLineWidth(context, 2.0);
    CGContextBeginPath(context);
    CGContextMoveToPoint(context, 20, 20);
    CGContextAddLineToPoint(context, 40, 20);
    CGContextStrokePath(context);

    CGContextSetStrokeColorWithColor(context, [UIColor yellowColor].CGColor);
    CGContextSetLineWidth(context, 2.0);
    CGContextBeginPath(context);
    CGContextMoveToPoint(context, 30, 10);
    CGContextAddLineToPoint(context, 30, 30);
    CGContextStrokePath(context);

}