संदर्भ के लिए आप अनुच्छेद शैलियों के इस वर्णन को पढ़ना चाहते हैं: Cocoa Paragraph Styles और ध्यान दें कि वहां सबकुछ पैराग्राफ के बीच पैराग्राफ के बीच अतिरिक्त स्थान जोड़ा गया है। आप अपने एनएसएमयूटेबल पैराग्राफ स्टाइल में शून्य को शून्य पर सेट कर सकते हैं लेकिन नहीं कम।
आगे कोड के लिए "6 1" के लिए लाइनों, उपयोग setMaximumLineHeight, धन्यवाद के बीच का अंतर हटना करने के लिए (मैं setMaximumLineHeight जोड़ने है):
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];
स्रोत
2014-05-12 17:38:46
आप NSTextView का उपयोग क्यों नहीं कर सकते? NSTextField आमतौर पर एकल पंक्ति पाठ फ़ील्ड के लिए उपयोग किया जाता है। – sidyll