Mac OS X可可,在全局屏幕坐标空间中翻转Y坐标 [英] Mac OS X Cocoa, Flipping Y Coordinate in Global Screen Coordinate Space
问题描述
如何将NSPoint的y值翻转到翻转的坐标空间.
How do I flip the y value of an NSPoint to a flipped coordinate space.
我有两个点的来源,都在全局屏幕空间中,但是其中一个被翻转了:
I have two sources of points, both in global screen space, but one is flipped:
-
一个屏幕坐标空间为0,0 =左上角.
one from a screen coordinate space with 0,0 = top left.
一个屏幕坐标空间为0,0 =左下角.
one from a screen coordinate space with 0,0 = bottom left.
我需要将第二个(左下)翻转到与第一个(左上)相同的空间.如何在NSPoint或CGPoint上做到这一点?
I need to flip the second one (bottom left) to be in the same space as the first one, top left. How can I do that on an NSPoint or CGPoint?
推荐答案
对于Mac OSX Cocoa,您可以翻转视图的 y
坐标,只需将 isFlipped
覆盖为为每个视图返回 YES
:
For Mac OSX Cocoa, you can flip the y
Coordinate for a view, just override isFlipped
to return YES
for each view:
- (BOOL)isFlipped {
return YES;
}
这篇关于Mac OS X可可,在全局屏幕坐标空间中翻转Y坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!