Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS like coordinate-system in Mac app

I just started with my first Mac App, but I realised that the coordinate-system is "flipped" (x = 0, y = 0 is in the lower left corner). I'm having a lot of trouble with UI programming because I'm used to the iOS coordinate-system.

My Question now is: Can I flip the coordinate-system of my App/Window forever so that I don't have to flip all my subviews also.

Thats my App: My apps window contains a NSScrollView with posts from recent to old. When I add my first post I want it to be right at the top of the scrollView.

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

like image 476
ferdyyy Avatar asked Mar 20 '23 08:03

ferdyyy


2 Answers

You can do a override of the method called - (BOOL)isFlipped in your NSView classes. Make it to return YES to get the iOS like coordinate system(AKA flipped). By default it returns NO, just like what you see now. Do so will also solve your second problem because the coordinates are flipped.

like image 131
Anton Avatar answered Mar 21 '23 22:03

Anton


you can change it programatically as TonyD has suggested or via interface builder in size inspector using origin pane

origin

like image 39
bikram990 Avatar answered Mar 21 '23 21:03

bikram990