核心图形坐标系 [英] Core Graphics coordinate system

查看:82
本文介绍了核心图形坐标系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当覆盖 drawRect 时,我发现那里的坐标使用0,0作为左上角。



但是《 Apple UIView编程指南》却这样说: 。例如,Core Graphics和OpenGL ES使用的坐标系的原点位于视图或窗口的左下角,并且y轴相对于屏幕向上。


我很困惑;

解决方案

本文档中的 Core Graphics是指石英,是的。只是简单化了。



当您自己创建 CGContext 时,其坐标系的原点位于左下角。当UIKit创建 CGContext 以便绘制到视图中时,在调用 -drawRect:之前,它有助于翻转坐标系。 / p>

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?

解决方案

"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:.

这篇关于核心图形坐标系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆