Я пытаюсь отобразить NSAlert
с дополнительным видом, чтобы я мог показать ссылку в блоке текста под информативным сообщением. Вот мой код.Аксессуар в NSAlert не отображает текст с правильным размером
#import "AppDelegate.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSAlert *activateAlert = [NSAlert alertWithMessageText: @"Some message text"
defaultButton: @"OK"
alternateButton: nil
otherButton: nil
informativeTextWithFormat: @"Some informative text"];
NSTextView *accessory = [[NSTextView alloc] initWithFrame: NSMakeRect(0,0,300,15)];
NSFont *font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
NSDictionary *textAttributes = @{NSFontAttributeName: font};
[accessory insertText:[[NSAttributedString alloc] initWithString:@"Some text in an accessory view"
attributes: textAttributes]];
accessory.editable = NO;
accessory.drawsBackground = NO;
[accessory setAutomaticLinkDetectionEnabled: YES];
activateAlert.accessoryView = accessory;
[activateAlert beginSheetModalForWindow: self.window
modalDelegate: nil
didEndSelector: nil
contextInfo: nil];
}
@end
Apple documentation говорит "информативный текст (который использует небольшой системный шрифт)", поэтому я использую [NSFont smallSystemFontSize]
, но это не делает правильно (see):
- Это не выровнены
- Он не использует небольшой размер шрифта (я пытался использовать другие значения, например, 1.0), но кажется, что атрибут шрифта игнорируется.
Любые подсказки? Должен ли я создать свой собственный компонент NSAlert
?
Спасибо!
Это выглядит как ошибка для меня. Я мог бы изменить шрифт, но не размер. – rdelmar
То же самое для меня. Также изменился цвет. –