I want to display the first 500 characters in a UILabel and display the Truncate icon if more than 500 characters are available. But I donβt know how to limit 500 characters to truncate the text?
Here is my code
label2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 350, self.bounds.size.width, 30)];
label2.backgroundColor = [UIColor clearColor];
label2.numberOfLines = 2;
label2.textAlignment = UITextAlignmentCenter;
label2.font = [UIFont systemFontOfSize:13];
[self addSubview:label2]
NSString *temp = [galleryEntryTree objectForKey:@"description"];
coverView.label2.text = temp;
coverView.label2.adjustsFontSizeToFitWidth = NO;
coverView.label2.lineBreakMode = UILineBreakModeTailTruncation;
Just tell me guys how I can display at least 500 characters and crop it (if longer than 500)
Any help is appreciated.
source
share