2013-10-15 9 views
9

मैं एक काले रंग की पृष्ठभूमि पर पाठ खींचने की कोशिश कर रहा हूं और पाठ को प्रस्तुत करने के तरीके में कुछ अंतर देख रहा हूं।एक काले रंग की पृष्ठभूमि पर NSTextField और NSTextView के बीच मतभेदों को प्रस्तुत करना

NSTextView * textView = [[NSTextView alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, 500.0f, 50.0f)]; 
[textView setDrawsBackground:YES]; 
[textView setBackgroundColor:[NSColor blackColor]]; 
[textView setString:@"NSTextView: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."]; 
[textView setFont:[NSFont fontWithName:@"Helvetica" size:18.0f]]; 
[textView setEditable:NO]; 
[textView setTextColor:[NSColor whiteColor]]; 

[flippedView addSubview:textView]; 

NSTextField * textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0.0f, 50.0f, 500.0f, 50.0f)]; 
[textField setDrawsBackground:YES]; 
[textField setBackgroundColor:[NSColor blackColor]]; 
[textField setBordered:NO]; 
[textField setBezeled:NO]; 
[textField setStringValue:@"NSTextField: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."]; 
[textField setFont:[NSFont fontWithName:@"Helvetica" size:18.0f]]; 
[textField setEditable:NO]; 
[textField setTextColor:[NSColor whiteColor]]; 

[flippedView addSubview:textField]; 

पाठ NSTextField अंदर बहुत अच्छा लगता है, लेकिन NSTextView के अंदर का पाठ भी बोल्ड दिखता है: यहाँ मेरी कोड है। मैं क्या गलत कर रहा हूं?

enter image description here

+0

आप लाइन 5,6,7 पर textfield क्यों हैं? –

+0

क्षमा करें, कॉपी और पेस्ट त्रुटि! – Aaron

उत्तर

0

NSTextField शायद गहरे रंग की पृष्ठभूमि है, जो कि तुम क्या चाहते हो सकता है नहीं है के बारे में अपने सेल बताता है:

यहाँ एक स्क्रीनशॉट है। यह बताओ प्रकाश पृष्ठभूमि के लिए प्रस्तुत करने के लिए:

[[textField cell] setBackgroundStyle:NSBackgroundStyleLight]; 
+0

मैंने समस्या दिखाने के लिए एक स्क्रीनशॉट जोड़ा है। NSTextField पाठ को पूरी तरह से प्रस्तुत करता है। यह NSTextView है जो 'गलत' दिखता है। – Aaron

0

मैं इस तरह की कोशिश की है बस अपने इस लाइन की जगह: -

//replace below this line 
    //[textView setFont:[NSFont fontWithName:@"Helvetica" size:18.0f]]; 
//Modified this below line 
NSFontManager *fontManager = [NSFontManager sharedFontManager]; 
     NSFont *regular = [fontManager fontWithFamily:@"Helvetica" 
                traits:NSUnitalicFontMask 
                weight:0 
                size:18.0f]; 
     [textView setFont:regular]; 
संबंधित मुद्दे