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?
The default coordinate system used by Core Graphics framework is LLO-based.
Core Graphics is a low-level 2D graphics framework that allows drawing device independent graphics. All 2D drawing in UIKit uses Core Graphics internally. Core Graphics supports drawing in a number of scenarios including: Drawing to the screen via a UIView . Drawing images in memory or on screen.
Overview. In the default Core Graphics coordinate space, the origin is located in the lower-left corner of the rectangle and the rectangle extends towards the upper-right corner.
The data structure CGPoint represents a point in a two-dimensional coordinate system. The data structure CGRect represents the location and dimensions of a rectangle. The data structure CGSize represents the dimensions of width and height.
"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:
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With