You must bother sometimes when you need to display a multi color text in your application! You must be using many uilabels with fissrent color. But you need not do this all. Here is a simple way to show your HTML file directly into UITextView.
What you need is to save all text into a html file and call that file in your UITextView with the help of this code bellow-
// Load the HTML sourceself.sourceText = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"htmlfile" ofType:@"html"]];[myTextView setContentToHTMLString:self.sourceText];
You may download the sample app from here
4 comments:
Thanks for such a nice tutorials.
It helped me a lot....
setContentToHTMLString is a non-public API and my app got rejected after using this.
Dont use this
if we cant use this setContentToHTMLString method then which method we shoud use?
In spanish I want say something: "Muchas gracias por este aporte increíble, realmente son cosas tan básicas pero tan necesarias y si no existiera gente como tu, que comparte el conocimiento, no se podrían hacer cosas grandes. FELICITACIONES POR ESTE APORTE AMIGO!".
Sinceramente Patrick!.
Post a Comment