当覆盖drawRect时,我发现那里的坐标使用0,0作为左上角.
但是Apple UIView编程指南说:
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.
我糊涂了;当他们在这里引用Core Graphics时,他们是在谈论与Quartz不同的东西吗?
解决方法
本文档中的“核心图形”意味着“Quartz”,是的.这只是过于简单化了.
当您自己创建CGContext时,其坐标系的原点位于左下角.当UIKit创建用于绘制视图的CGContext时,它会在调用-drawRect:之前有助于翻转坐标系.