IOS as a coordinate system in a Mac application

I just started my first Mac App, but I realized that the coordinate system is β€œupside down” (x = 0, y = 0 is in the lower left corner). I have a lot of problems with user interface programming because I'm used to the iOS coordinate system.

My question now is: Can I flip the coordinate system of my application / Window forever so that I do not have to flip all my routines.

This is my application: The My Applications window contains an NSScrollView with messages from recent to old. When I add my first post, I want it to be at the top of scrollView.

I hope someone had the same problem and can help me. Thanks

+4
source share
2 answers

You can override a method called - (BOOL)isFlippedin your NSView classes. Do this to return YESto get a coordinate system similar to iOS (AKA rolled over). By default, it returns NO, exactly as you see now. This will also solve your second problem, because the coordinates are upside down.

+5
source

you can change it programmatically, as suggested by TonyD, or through the interface constructor in the size inspector using the start area

origin

+1
source

Source: https://habr.com/ru/post/1544683/


All Articles