PDA

View Full Version : Drawing a grid in Core Graphics




Blakeasd
Nov 20, 2010, 09:44 PM
Hello Everyone,
I am trying to create a grid using a custom view, but I just can't get it how I want it. I am trying to draw something very simple, but it's not working. This is what I am trying to draw:
http://www.instructables.com/image/FK077AIFR12319A/X-Y-Axis-Graph.jpg
Does anyone know how to draw this in a custom view? Thanks



lloyddean
Nov 20, 2010, 10:36 PM
Show what code you've tried and are not happy with.

robbieduncan
Nov 21, 2010, 04:07 AM
Show what code you've tried and are not happy with.

Very much this! One thing I would note: if you want crisp lines then draw at 0.5 increments. The reasons for this are due to the way Quartz anti-aliases. So a line from (0,0.5) to (10,0.5) would look like a crisp single-pixel line and (0,0) to (10,0) would look like it was straddling the pixel boundary and be anti-aliases across two pixels.