icon
アラートウインドに表示されるアイコン画像
解説
アラートウインドに表示されるアイコン画像
●警告
●インフォーメーション(アプリケーションのアイコン画像)
古い画像をアイコンに使ったとき、「Command CodeSign failed with a nonzero exit code」というエラーが出てハマった。
リソースフォークがついているとだめらしい。
xattr -c -r "対象のファイル"
で削除して、クリーンアンドビルドでOK
When I used an old image for an icon .I got an error called "Command CodeSign failed with a nonzero exit code" and got addicted.
No fork with a resource fork.
xattr -c -r "targetImageFile"
Process with this command.
フレームワーク
ApplicationKit
クラス
NSAlert
使用可能
10.3-
編集時のバージョン
OS X 10.14 swift5.1
参照
-setIcon:
例文
NSLog([[alert icon] description]);
swift5.1
@IBAction func function014(sender: AnyObject) { //End even if there are other modals. NSApp.abortModal() //Create NSAlert let alert:NSAlert = NSAlert() //Set icon image let imageObj:NSImage = NSImage(imageLiteralResourceName: "anIcon") //Make alert icon image an imageObj alert.icon = imageObj //1st button alert.addButton(withTitle: NSLocalizedString("Stop", comment:"停止")) //2nd button alert.addButton(withTitle: NSLocalizedString("Continue", comment:"")) //Display sheet alert.beginSheetModal(for: self.view.window!) { responseCode in if NSApplication.ModalResponse.alertSecondButtonReturn == responseCode { //paste when second button is pressed print("SecondButton") //Set image to image view on window self.imageView.image = imageObj } } }
//NSAlert icon @IBOutlet weak var imageView: NSImageView! @IBAction func function014(sender: AnyObject) { NSLog("function014 called") //なにかモーダルがあっても終わり NSApp.abortModal() //テキストの作成 let messageText:String = "Message text" as String let informativeText:String = "Information text" as String //NSAlertの作成 let alert:NSAlert = NSAlert() let anApplication = NSApplication.sharedApplication() var imageObj:NSImage = NSImage(named: "anIcon")! // var imageObj:NSImage = anApplication.applicationIconImage alert.icon = imageObj //1つめのボタン alert.addButtonWithTitle(NSLocalizedString("Stop", comment:"停止")) //2つめのボタン alert.addButtonWithTitle(NSLocalizedString("Continue", comment:"")) //シートを出す alert.beginSheetModalForWindow(window) { responseCode in if NSAlertSecondButtonReturn == responseCode { NSLog("SecondButton") self.imageView.image = imageObj } } }