I'm trying to draw a simple line, the problem is that it is coming out not as 1 pixel in width but 2. The docs state that user space units will translate to a pixel, if I read it correctly.
The code is as simple as it gets, yet my line is always 2 pixels wide.
//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);
No points don't translate to pixels. If your line is too thick change the value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With