I am creating a report & printing the same on a UITextView.My report has some titles and there respective subtitles. I am printing 1st title then its subtitle & then second title and its subtitle and so on. I want different font and font sizes for the titles and subtitles.
But the problem is the text field always prints the last subtitle.If any one know solution to this problem,let me know.
Here is what i have dome in my .m file
- (void) printData {
// data is UITextView object
[data setFont:[UIFont fontWithName:@"Helvetica" size:15]];
NSString *title = @"TITLE" ;
data.text = title;
[data setFont:[UIFont fontWithName:@"Arial" size:15]];
NSString *subtitle = @"SUBTITLE" ;
data.text = subtitle;
}
First of all I would Use
UITextViewinstead ofUITextField, as it is build for long text.If you just keep calling the method text of either
UITextFieldorUITextView, the currently residing text will be replaced with your last text. To avoid that you have to append new text to the text that is already residing in theUITextFieldorUITextView.As for the fonts. The font property applies to the entire
UITextFieldandUITextViewcontent.What you could do in your case is to use
UIWebViewand render your text using HTML.