How to Draw Thin Lines Using Core Graphics

When creating my own custom graphing engine I had wanted to have very thin (1px) grid lines so that the data lines would stand out by being thicker. Now you might be thinking well by default when using CG drawing the lines are 1px. This is true but when they are draw half a pixel is drawn on each side making them 2px lines.There is a trick however to overcome this, and it is to offset the lines start and end point by half a pixel in the y-axis. This prevents CG from drawing the added half pixel on each side. So in effect you get a true 1px line.

So for example if your line was going to be from (10 , 30) to (20 , 30) instead make it from (10 , 30.5) to (20 , 30.5)

Hope this helps:)


No Responses Yet to “How to Draw Thin Lines Using Core Graphics”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: