PaintCode NSButton displays upside-down

前提是你 提交于 2019-12-24 12:28:38

问题


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:

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:


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:



来源:https://stackoverflow.com/questions/35896226/paintcode-nsbutton-displays-upside-down

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!