Search code examples
swiftnsviewnsbuttonpaintcode

PaintCode NSButton displays upside-down


I am using PaintCode to create a button. I import the StyleKit, and create the NSButton Class for my RankView button. Like this:

import Cocoa

@IBDesignable
class RankView: NSButton {

    override func drawRect(dirtyRect: NSRect) {
        super.drawRect(dirtyRect)
        StyleKit.drawRank2()

        // Drawing code here.
    }

}

But when I run the app, (and even in the storyboard), the button is upside-down. Like this: enter image description here

The arrow should be Up, but it points down.

Whenever I change the parent class to NSView it displays properly. Any ideas why this is happening/how to fix it?


Solution

  • NSButton uses flipped coordinates by default (its isFlipped method returns YES).

    To support these kinds of views, change the origin of the canvas in PaintCode like this:

    enter image description here