0

From alerts, I'm assuming this picture represents is a panel, not a sheet (my understanding is that sheets are overlays over already open apps).

I'm looking to create a custom, or just built in 'clean' popup alert (notification). I can't seem to find anything within NSAlert that speaks of customizing the alert - alertType seems like it might but apparently it is for conveying importance.

An example is something like this:

enter image description here

(source: http://i.stack.imgur.com/WJhV8.jpg)

4

1 回答 1

3

NSUserNotificationCenter类用于在屏幕右上角显示这些“用户通知” :

通知示例

import AppKit

let note = NSUserNotification()
note.title = "Hi Stack Overflow"
note.subtitle = "How’s it going?"
note.contentImage = NSImage(contentsOfURL: NSURL(string: "http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png")!)

NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(note)

(您从 Gmail 中看到的是 Chrome 提供的自定义非标准通知系统。如果您编写 Chrome 扩展程序,您可能可以利用它,但 NSUserNotificationCenter 更正常。)

于 2015-09-29T20:42:53.103 回答