I have a UILabel attached to a UIScrollView.
The Label is getting its attributed text from a .rtf(Rich Text File). The code I'm using to achieve this is:
string =
[NSAttributedString.alloc
initWithFileURL:[ NSBundle.mainBundle URLForResource:@"fileName" withExtension:@"rtf" ]
options:nil
documentAttributes:nil
error:NULL
];
I am then passing the "string"(attributedString) to my UILabel like so
[self.Label setAttributedText:string];
self.Label.numberOfLines = 0;
self.Label.textAlignment = NSTextAlignmentCenter;
self.Label.font = [self.Label.font fontWithSize:(long)fontSize];
This all takes place in the ViewDidLoad.
My problem is that it takes a very long time to process this line: [self.Label setAttributedText:string];
Switching from one view to this view can take seconds.
Furthermore, when I try to change the font of the self.Label it takes a very long time as well.
I know the problem is with the UILabel processing the attributedString I'm just not sure why and how to fix it.
Important Note: The easy answer is use a UITextView, I don't want to because scrolling long non-english text in a UITextView is choppy and slow. Users have complained about it and after much research I've concluded that UILabel in a scrollView is the only way to achieve smooth scrolling for this application.