NSTextView *accessory = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,200,15)];
NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
[accessory insertText:[[NSAttributedString alloc] initWithString:@"新的颜色设置保存完成."
attributes:textAttributes]];
[accessory setEditable:NO];
[accessory setDrawsBackground:NO];
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"通知信息:";
// [alert setInformativeText:@"Informative text."];
alert.accessoryView = accessory;
[alert runModal];
[alert release];
本文档展示了如何使用Objective-C在MacOS上创建一个带有自定义文本的通知弹窗,其中包括了设置字体、文本不可编辑及背景不绘制等操作。

2254

被折叠的 条评论
为什么被折叠?



