Question

I'm new in Mac programming. The first thing I've noticed is that the (0, 0) coordinate in a NSView is the bottom-left corner.

I'm going to use a NSView as a canvas, to draw objects on it. My objects will be positioned from the top-left corner. I can convert Y coordinates using a geometrical transformation.

But the problem is: I'm not sure how to proceed when the view is resized. I don't want to calculate the layout every resize event, because calculating it takes between 150 and 250 ms.

So, to Mac experts:

  1. Do you know a good practice calculating the layout based on the top-left corner?
  2. How should I manage the resize behavior?
  3. Do you know other techniques, flipping the graphics object, or something like that, to draw this kind of stuff?
Was it helpful?

Solution

Just implement - (void)isFlipped { return YES; }

In your NSView subclass.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top