【问题标题】:PaintCode NSButton displays upside-downPaintCode NSButton 显示颠倒
【发布时间】:2016-03-11 07:31:28
【问题描述】:

我正在使用 PaintCode 创建一个按钮。我导入 StyleKit,并为我的 RankView 按钮创建 NSButton 类。像这样:

import Cocoa

@IBDesignable
class RankView: NSButton {

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

        // Drawing code here.
    }

}

但是当我运行应用程序时(甚至在情节提要中),按钮是颠倒的。像这样:

箭头应该向上,但它指向下方。

每当我将父类更改为 NSView 时,它都会正确显示。任何想法为什么会发生这种情况/如何解决它?

【问题讨论】:

    标签: swift nsview nsbutton paintcode


    【解决方案1】:

    NSButton 默认使用翻转坐标(它的 isFlipped 方法返回 YES)。

    要支持这些类型的视图,请在 PaintCode 中更改画布的原点,如下所示:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多