0

我似乎无法增加 NSAlert 的字体大小,甚至无法增加整个框的大小。

else if array[arraycount].containsString("Error: error.") {
   let myPopup: NSAlert = NSAlert()
   myPopup.alertStyle = NSAlertStyle.WarningAlertStyle
   myPopup.addButtonWithTitle("I've Called!")
   myPopup.informativeText = "Sorry, we weren't able to that. Please Call Support 1(800)234-4567 ext: 12345"
   myPopup.runModal()
   let app = NSRunningApplication.currentApplication()                           
   app.activateWithOptions(.ActivateIgnoringOtherApps)
 }

这是我当前运行良好的代码,但我将在 iMac 上运行我的 OS X 应用程序,并且文本看起来非常小。我想以编程方式增加点大小,但我在 Swift 中找不到任何相关信息。任何帮助,将不胜感激!

4

2 回答 2

1

不要设置informativeText,那真的很小。

相反,设置messageText. 那更大,更大胆。

更好的是,两者都设置,所以更重要的信息大而粗,不太重要的信息小。

myPopup.messageText = "Sorry, we weren't able to that."
myPopup.informativeText = "Please Call Support 1(800)234-4567 ext: 12345"
于 2016-07-29T15:54:52.643 回答
0

在警报中还可以选择使用附件视图。

let accessory = NSTextView(frame: CGRect(x: 0, y: 0, width: 200, height: 20))
let attributes : [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: NSFont.systemFont(ofSize: 13)]
let accessoryText = "Some more readable text"
let accessoryAttributedText = NSAttributedString(string: accessoryText, attributes: attributes)
accessory.textStorage!.setAttributedString(accessoryAttributedText)
accessory.isEditable = false
accessory.drawsBackground = false
alert.accessoryView = accessory
于 2021-04-25T20:49:27.720 回答