Search code examples
objective-cxcodegraphing

What is the line of code to draw axes (x and y) in a custom view?


I am trying to draw a plane on which can be graphed on by a calculator, and I know you can draw axis with one or a few lines of code but i do not know what they are.

Thanks


Solution

  • I believe what you are looking for is NSBezierPath. It has methods like:

    + (void)strokeLineFromPoint:(NSPoint)point1 toPoint:(NSPoint)point2
    

    You may also want to take a look at NSColor which you will need to use to set what the stroke color is.

    In iOS, the roughly equivalent class is UIBezierPath.