Ios – Core Graphics coordinate system

core-graphicsiosquartz-graphicsuiview

When overriding drawRect I've found that the coordinates there use 0,0 as the upper left.

But the Apple UIView Programming Guide says this:

Some iOS technologies define default coordinate systems whose origin point and orientation differ from those used by UIKit. For example, Core Graphics and OpenGL ES use a coordinate system whose origin lies in the lower-left corner of the view or window and whose y-axis points upward relative to the screen.

I'm confused; are they talking about something different than Quartz when they refer to Core Graphics here?

Best Answer

"Core Graphics" in this documentation means "Quartz", yes. It's just an oversimplification.

When you create a CGContext yourself, its coordinate system has the origin in the bottom-left. When UIKit creates the CGContext for drawing into a view, it helpfully flips the coordinate system before calling -drawRect:.

Related Topic