title: Drawing a very thin line with CGContextAddLineToPoint and CGContextSetLineWidth
body: <p>I want to draw a very thin hairline width of a line in my UIView's drawRect method. The line I see that has a value 0.5 for CGContextSetLineWidth doesn't match the same 1.0 width value that is used to draw a border CALayer.</p>
  
  <p>You can see the difference between the two - the red line (width = 1) is a lot thinner than the purple/blue line (width = 0.5).</p>
  
  <p><img src="https://i.stack.imgur.com/4Fkcd.png" alt="Border drawn with CALayer"></p>
  
  <p>Here's how I am drawing my pseudo 1.0 width horizontal line:</p>
  
  <pre><code>CGContextRef ctx = UIGraphicsGetCurrentContext();
  CGContextSetStrokeColorWithColor(ctx, [UIColor blueColor].CGColor);
  CGContextSetLineWidth(ctx, 0.5); // I expected a very thin line
  
  CGContextMoveToPoint(ctx, 0, y);
  CGContextAddLineToPoint(ctx, self.bounds.size.width, y);
  
  CGContextStrokePath(ctx);
  </code></pre>
  
  <p>Here's a border for the same view, this time using 1.0 border width:</p>
  
  <pre><code>UIView *myView = (UIView *)self;
  CALayer *layer = myView.layer;
  layer.borderColor = [UIColor redColor].CGColor;
  layer.borderWidth = 1.0;
  </code></pre>
  
  <p>What do I need to do differently to draw my own custom line that's the same width as the CALayer version?</p>