开发者

NSAlert - can you have a custom icon?

开发者 https://www.devze.com 2023-02-01 04:27 出处:网络
Is the开发者_运维技巧re a way to insert a custom icon in a NSAlert? I know you can have different prefabbealert styles but is it possible to cuYes. You can use

Is the开发者_运维技巧re a way to insert a custom icon in a NSAlert? I know you can have different prefabbealert styles but is it possible to cu


Yes. You can use

- (void)setIcon:(NSImage *)icon

Look at the documentation.


Swift:

let alert = NSAlert()
alert.messageText = "My message"
alert.addButton(withTitle: "OK")
alert.alertStyle = .informational
alert.icon = img
alert.runModal()
0

精彩评论

暂无评论...
验证码 换一张
取 消