【发布时间】:2011-12-11 13:31:25
【问题描述】:
我有一个带有附件视图和三个按钮的 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];
【问题讨论】: