gpt4 book ai didi

swift - 自定义 NSAlert 复选框和按钮的外观

转载 作者:行者123 更新时间:2023-11-30 10:32:42 24 4
gpt4 key购买 nike

NSAlert 的默认外观似乎不太理想。例如,当我单击复选框时,该复选框会消失,并且聚焦的按钮具有白色文本。

[编辑]我应该提到这是一个 Metal 应用程序。

以下是创建 NSAlert 的代码(使用 SnapKit 进行约束):

                let aview = NSView(frame: NSRect(x: 0, y: 0, width: 150, height: 70))
let btn = NSButton(checkboxWithTitle: "Sound", target: nil, action: nil)
let btn1 = NSButton(checkboxWithTitle: "Music", target: self, action: #selector(handleMusicToggle(_:)))
aview.addSubview(btn)
aview.addSubview(btn1)

btn.snp.makeConstraints { (make) in
make.leading.equalToSuperview()
make.top.bottom.equalToSuperview()
}
btn1.snp.makeConstraints { (make) in
make.leading.equalTo(btn.snp.trailing)
make.trailing.equalToSuperview()
make.top.bottom.equalToSuperview()
}

let alert = NSAlert()
alert.messageText = "PAUSED"
alert.informativeText = "BLOKKIT is paused"
alert.alertStyle = .warning
alert.accessoryView = aview
alert.addButton(withTitle: "RESUME")
alert.addButton(withTitle: "QUIT")
let response = alert.runModal()

以下是 NSAlert 外观的屏幕截图: enter image description here

最佳答案

有关信息,这是我得到的信息:

enter image description here

关于swift - 自定义 NSAlert 复选框和按钮的外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58792060/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com