How to Translate iOS UIView Point to Mac NSView



I’m converting some Manual Layout code from iOS to Mac.

I’m overriding “layout” in my class, it calculates and sets the Frame Rect for all its subviews. This works ok on Mac, except, as expected, everything is flipped in Y. I’m now trying to figure out how to flip the Y Coordinate.

Given that I have calculated the Frame Rect of a subview correctly, I’m then doing this:

myCalculatedFrameRect = the top, left Rectangle

myRect.origin.y = self.frame.size.height - myCalculatedFrameRect.origin.y;

[mySubview setFrame: myRect];

Which doesn’t work!

self in this case is the View I’m laying out, e.g. the superview of the subview,

What magic do I need to make this work? I was wondering if I should “flip” the View with the “isFlipped” method, but I’m not sure what other problems this might cause and would rather just flip the Coordinate in the layout method…..

All the Best

Join to automatically receive all group messages.