मैं केंद्र संरेखण के साथ कोको एनएसवी व्यू में नई लाइनों (\ n) के साथ एक स्ट्रिंग खींचने की कोशिश कर रहा हूं। उदाहरण के लिए अगर मेरे स्ट्रिंग है:कोको में केंद्र संरेखण के साथ टेक्स्ट ड्रा
NSString * str = @"this is a long line \n and \n this is also a long line";
मैं इस चाहते हैं कुछ हद तक प्रकट करने के लिए के रूप में:
this is a long line
and
this is also a long line
यहाँ NSView drawRect विधि अंदर मेरे कोड है:
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setAlignment:NSCenterTextAlignment];
NSDictionary * attributes = [NSDictionary dictionaryWithObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
NSString * mystr = @"this is a long line \n and \n this is also a long line";
[mystr drawAtPoint:NSMakePoint(20, 20) withAttributes:attributes];
यह अभी भी ड्रॉ बाएं संरेखण के साथ पाठ। इस कोड के साथ क्या समस्या है?
क्या मैं अभी भी कचरा संग्रह का उपयोग कर रहा था अगर मैं पैराग्राफ स्टाइल लीक करूँगा? – AmaltasCoder
@Amal यदि आप कचरा संग्रह का उपयोग कर रहे हैं, तो कोई रिसाव नहीं है। –