gpt4 book ai didi

ios - 在什么情况下,iOS 上的坐标空间是(未翻转的)默认值?

转载 作者:行者123 更新时间:2023-12-01 18:42:05 25 4
gpt4 key购买 nike

根据documentation for CGRect

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. If the context has a flipped-coordinate space—often the case on iOS—the origin is in the upper-left corner and the rectangle extends towards the lower-right corner.



我一直认为 iOS 上的坐标系从左上角开始,但在阅读后,它被翻转而不是默认坐标空间是有道理的。您不会像在 iOS 上那样考虑笛卡尔图上的点,其中添加到 Y 值会向下移动,而不是向上移动。

文档说它“经常如此”,那么 iOS 上什么时候不是这种情况? Core Graphics 默认的坐标空间在哪些平台上?

最佳答案

在 iOS 和 UIKit 中,原点位于左上角,正 y 值朝向屏幕底部。

但是对于较低级别的 Quartz API,原点位于左下角,y 值朝屏幕顶部上升。

Quartz 2D Programming Guide 中对此进行了介绍在标题为 Drawing to a View Graphics Context in iOS 的部分下.

The default coordinate system used throughout UIKit is different from the coordinate system used by Quartz. In UIKit, the origin is in the upper-left corner, with the positive-y value pointing downward. The UIView object modifies the CTM of the Quartz graphics context to match the UIKit conventions by translating the origin to the upper left corner of the view and inverting the y-axis by multiplying it by -1. For more information on modified-coordinate systems and the implications in your own drawing code, see Quartz 2D Coordinate Systems.



所以“通常情况下”是在使用 UIKit 时。使用较低级别的 Quartz API 时并非如此。

关于ios - 在什么情况下,iOS 上的坐标空间是(未翻转的)默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41455301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com