How do you flip the coordinate system of an NSView?

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
        }
    }
}

The idea is that each individual view has its own way of drawing itself (for example, using human-calculated paths) that might get really wonky if you suddenly flip its coordinate plane (rasters might be fine while paths might draw upside-down, calculations might place things off-screen, Bézier control points might get twisted, etc.). So it's not settable, but subclasses can specify isFlipped because they should definitely know how the view is drawn.

Subclasses can also make it settable, but then they must expect it to change at any time.

As for code, here's Jay's answer in Swift 5:

open class FlippedView: NSView {
    override var isFlipped: Bool { true }
}