我似乎无法增加我的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中找到任何关于它的信息。任何帮助将不胜感激!
答案 0 :(得分:1)
不要设置informativeText
,这真的很小。
而是设置messageText
。那个更大,更大胆。
更好的是,设置两者,所以更重要的信息是大而大胆的,不太重要的信息很小。
myPopup.messageText = "Sorry, we weren't able to that."
myPopup.informativeText = "Please Call Support 1(800)234-4567 ext: 12345"
答案 1 :(得分: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