ios – CGContext线宽

我试图绘制一条简单的线,问题是它的宽度不是1像素,而是2.如果我正确读取,文档说明用户空间单位将转换为像素.

代码很简单,但我的行总是2像素宽.

//Get the CGContext from this view
CGContextRef context = UIGraphicsGetCurrentContext();
//Set the stroke (pen) color
CGContextSetStrokeColorWithColor(context,[UIColor blueColor].CGColor);

//Set the width of the pen mark
CGContextSetLineWidth(context,1);

for (int i = 1; i <= sections - 1; i++)
{
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(0.0,i * kSectionHeight)];

    CGContextMoveToPoint(context,0.0,i * kSectionHeight); //Start point
    CGContextAddLineToPoint(context,self.frame.size.width,i * kSectionHeight);
}

CGContextStrokePath(context);

解决方法

没有点不会转换为像素. 如果您的线太粗,请更改该值.

以上是来客网为你收集整理的ios – CGContext线宽全部内容,希望文章能够帮你解决ios – CGContext线宽所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。