问题
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