我有一个带有附件视图和三个按钮的 NSAlert,这些按钮没有向右对齐(对于 LTR 系统),但似乎扩展到附件视图的宽度,如下所示
同时删除附件视图,三个按钮在右侧未正确对齐
如何解决这个问题?我不想替换自己编写代码的 NSAlert,为什么我必须重新发明轮子?
我使用的代码由setAccessoryView文档复制并在下面报告
NSTextView *accessory = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,600,15)];
NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
[accessory insertText:[[NSAttributedString alloc] initWithString:@"Text in accessory view"
attributes:textAttributes]];
[accessory setEditable:NO];
[accessory setDrawsBackground:NO];
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Message text"];
[alert setInformativeText:@"Informative text"];
[alert setAccessoryView:accessory];
[alert addButtonWithTitle:@"Btn 3"];
[alert addButtonWithTitle:@"Btn 2"];
[alert addButtonWithTitle:@"Btn 1"];
[alert runModal];
[alert release];