0

My data is coming From Server with Html Tags.

I want to display it on my Text View as it's format (Bold, Font, etc). How can i display it?

Thanks in Advance

Venkat.R
  • 7,420
  • 5
  • 42
  • 63
Jayesh
  • 35
  • 4

2 Answers2

0
NSString *infoString =@"I am iOS developer.";

    NSMutableAttributedString *attString=[[NSMutableAttributedString alloc] initWithString:infoString];

    UIFont *font_regular=[UIFont fontWithName:@"Helvetica" size:20.0f];
    UIFont *font_bold=[UIFont fontWithName:@"Helvetica-Bold" size:20.0f];

    [attString addAttribute:NSFontAttributeName value:font_regular range:NSMakeRange(0, 4)];

    [attString addAttribute:NSFontAttributeName value:font_bold range:NSMakeRange(5, 18)];

    [self.txtView setAttributedText:attString];
Ramesh_T
  • 1,251
  • 8
  • 19
  • Possible duplicate question: http://stackoverflow.com/questions/20992950/ios7-font-size-change-when-create-nsattributedstring-from-html – Ramesh_T Jan 14 '16 at 10:57
0

I use Web View For this. Create one object and load that string to web view. [_webView loadHTMLString:[strDescription description] baseURL:nil]; // set string to web view

For increase Dynamic Height of Web View:

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    CGRect frame = _webView.frame;
    frame.size.height = 1;
    _webView.frame = frame;
    CGSize fittingSize = [_webView sizeThatFits:CGSizeZero];
    frame.size = fittingSize;
    _webView.frame = frame;
    [self.view layoutIfNeeded];
    NSLog(@"size: %f, %f", fittingSize.width, fittingSize.height);
    _bgScrollView.contentSize = CGSizeMake(320, fittingSize.height+370);
}
Jayesh
  • 35
  • 4