问题描述
我正在使用 PaintCode 创建一个按钮.我导入 StyleKit,并为我的 RankView 按钮创建 NSButton 类.像这样:
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.
每当我将父类更改为 NSView 时,它都会正确显示.任何想法为什么会发生这种情况/如何解决它?
Whenever I change the parent class to NSView it displays properly. Any ideas why this is happening/how to fix it?
推荐答案
NSButton 默认使用翻转坐标(它的 isFlipped 方法返回 YES).
NSButton uses flipped coordinates by default (its isFlipped method returns YES).
要支持这些类型的视图,请像这样更改 PaintCode 中画布的原点:
To support these kinds of views, change the origin of the canvas in PaintCode like this:
这篇关于PaintCode NSButton 显示倒置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!