PaintCode NSButton displays upside-down

2019-07-25 12:47发布

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?

1条回答
叛逆
2楼-- · 2019-07-25 13:35

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

查看更多
登录 后发表回答