I have created an NSScrollView in interface builder that has a variable number of semi-unique NSViews that can be programmatically added and removed from it. When I add subViews to the documentView, they appear in the lower-left hand corner instead of the upper-left hand corner. I see that you can check the isFlipped bool to figure out if the view's coordinate system is flipped, but I cannot find a way to set it as flipped.
Anyone know what I'm missing?
In your NSView
subclass, override isFlipped
:
isFlipped
A Boolean value indicating whether the view uses a flipped coordinate system.
Declaration
var isFlipped: Bool { get }
Discussion
The default value of this property is
false
, which results in a non-flipped coordinate system.[...]
If you want your view to use a flipped coordinate system, override this property and return
true
.
Source: isFlipped - NSView | Apple Developer Documentation
For anyone wishing to do this in Swift here's how you override in your custom class:
class FlippedView: NSView { override var isFlipped { get { return true } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With