Per riferimento si desidera leggere questa descrizione degli stili di paragrafo: Cocoa Paragraph Styles e si noti che tutto ciò che c'è dentro è uno spazio aggiuntivo aggiunto tra le righe, tra paragrafi, prima dei paragrafi, ecc. È possibile impostare i valori in NSMutableParagraphStyle a zero ma non inferiore.
a ridursi ulteriormente la spaziatura tra le righe, l'uso setMaximumLineHeight, grazie a "6 1" per il codice (ho aggiungere il setMaximumLineHeight):
versione
NSString *title = @"title here";
NSFont *bold14 = [NSFont boldSystemFontOfSize:14.0];
NSColor *textColor = [NSColor redColor];
NSMutableParagraphStyle *textParagraph = [[NSMutableParagraphStyle alloc] init];
[textParagraph setLineSpacing:10.0]; // this sets the space BETWEEN lines to 10points
[textParagraph setMaximumLineHeight:12.0]; this sets the MAXIMUM height of the lines to 12points
NSDictionary *attrDic = [NSDictionary dictionaryWithObjectsAndKeys:bold14, NSFontAttributeName, textColor, NSForegroundColorAttributeName, textParagraph, NSParagraphStyleAttributeName, nil];
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:title attributes:attrDic];
[self.titleField setAllowsEditingTextAttributes:YES];
[self.titleField setAttributedStringValue:attrString];
fonte
2014-05-12 17:38:46
Perché non è possibile utilizzare NSTextView? NSTextField viene generalmente utilizzato per campi di testo a riga singola. – sidyll