When we create and run an NSAlert, by default it has a Message text (set to Alert by default) and an informative text (set to nil by default). Suppose one needs to customize the fonts for these texts, then how can one do this? There is no direct API as such for this in NSAlert class.
Here is how we need to proceed:
//Alloc and init a NSAlert.
1. NSAlert* alert = [[NSAlert alloc] init];
//Get all views present on the NSAlert content view. 5th element will be a NSTextField object holding the Message text.
2. NSArray* views = [[[alert window] contentView] subviews];
//Create a font.
3. NSFont *font = [NSFontfontWithName:@"Helvetica"size:10.0];
//Set font for Message text
4. [[views objectAtIndex:4] setFont:font];
//Set Message text and run.
5. [[views objectAtIndex:4]setStringValue:@"Custom Alert Text"];
6. Simmilarly for informative text do the above operation for element at 6th position(index 5) of views array.