So I'm trying to convert an NSRect to a CGRect. I used NSRectToCGRect() which copies everything over finely, but does not take into account y-origin axis.

The problem: A CGRect origin of (0,0) is the top left. NSRect origin (0,0) is bottom left.

Thus an NSRect (0,0,100,100) box is positioned at the bottom left of your screen, while a CGRect (0,0,100,100) box is placed at the top left of your screen.

I have a hack that fixes the y-origin through basic math:

fixedOriginY = screenHeight - NSRect.size.height - NSRect.origin.y

Thus the equivalent of an NSRect (0,0,100,100) is actually CGRect (0,800,100,100) (on my 900px height MBA). However I don't like this, I have a feeling it will break/have issues with retina or future complications.

Does anyone have a solution or idea on how to correctly convert NSRect to CGRect?

Edit
Report