Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.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
Iphone 石英2D-绘制点_Iphone_Ios_Macos_Quartz 2d - Fatal编程技术网

Iphone 石英2D-绘制点

Iphone 石英2D-绘制点,iphone,ios,macos,quartz-2d,Iphone,Ios,Macos,Quartz 2d,我知道在Quartz 2D中使用绘制直线的方法绘制点是非常有用的 CGContextMoveToPoint(context,x,y-0.5f); CGContextAddLineToPoint(context,x,y+0.5f); 有没有其他可能的方法用石英画一个点? 我的意思是,有一些直接的方法吗?如果你想让它看起来像一个圆点,试试这个: CGContextMoveToPoint(context,x,y-0.5f); CGContextAddLineToPoint(context,x,y+0

我知道在Quartz 2D中使用绘制直线的方法绘制点是非常有用的

CGContextMoveToPoint(context,x,y-0.5f);
CGContextAddLineToPoint(context,x,y+0.5f);
有没有其他可能的方法用石英画一个点?
我的意思是,有一些直接的方法吗?

如果你想让它看起来像一个圆点,试试这个:

CGContextMoveToPoint(context,x,y-0.5f);
CGContextAddLineToPoint(context,x,y+0.5f);
CGContextFillRect(context, CGRectMake(x,y,1,1));
CGContextStrokeEllipseInRect(context, CGRectMake(x, y, 4, 4));

它将为您绘制一个矩形内的椭圆(上面的案例显然是一个正方形)。我希望你选择一个正方形,因为它看起来像一个真正的圆形,而不是椭圆形。然而,这个圆圈从里面是空的,你可以用笔划填充它。(但它看起来很酷!):)

你说的“点”是什么意思?像素?一个逐点尺寸的矩形?显示的代码画了一条对角线,而不是一个点。@NikolaiRuhe oops添加了错误的代码。对不起,已编辑。我指的是一个像素
CGContextMoveToPoint(context,x,y-0.5f);
CGContextAddLineToPoint(context,x,y+0.5f);