पैराग्राफ में लाइनों की संख्या को सीमित करने का कोई तरीका है NSAttributedString?
मैं में दो तारों को जोड़ रहा हूं NSAttributedString और मैं उन्हें अधिकतम 3 लाइनों के लिए चाहता हूं, पहली स्ट्रिंग 1-2 लाइनें होगी, यदि आवश्यक हो तो छोटा कर दिया जाएगा।
सीमाओं की एनएसएट्रिब्यूटेड स्ट्रिंग संख्या
this is my first string
if its too long i't will get trun...
But this is my second string
मैं क्या किया है::
// First string
NSAttributedString *first = [[NSAttributedString alloc] initWithString:@"this is my first string if its too long i't will get trunticated"
attributes:@{NSForegroundColorAttributeName:[UIColor redColor],
NSFontAttributeName:[UIFont fontWithName:@"HelveticaNeue-Light" size:17.0]];
[str appendAttributedString:first];
// New line
[str appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
// Add photo count
NSAttributedString *second = [[NSAttributedString alloc] initWithString:@"But this is my second string"
attributes:@{NSForegroundColorAttributeName:[UIColor redColor],
NSFontAttributeName:[UIFont fontWithName:@"HelveticaNeue-Light" size:14.0]}];
[str appendAttributedString:second];
लेकिन परिणाम है:
this is my first string
if its too long i't will get
trunticated
और दूसरी स्ट्रिंग अंतिम पंक्ति
कुछ की तरह पर हमेशा होना चाहिए पहली स्ट्रिंग पहली 3 लाइनें लेती है और दूसरी स्ट्रिंग को लेबल से बाहर धक्का देती है।
मैं पहले स्ट्रिंग पैराग्राफ को 2 लाइनों तक सीमित कैसे कर सकता हूं?
क्या आप अभी तक इसे हल करने में सक्षम हैं? – ZeMoon
नहीं ... अभी के लिए मैं बस दो अलग-अलग लेबल का उपयोग करता हूं – ItayAmza