我的数据来自带有Html标记的服务器。
我想把它显示在我的文本视图中,因为它的格式(Bold,字体等等)。我该怎么显示呢?
Thanks in Advance
发布于 2016-01-18 05:49:38
我使用Web视图来实现这个功能。创建一个对象并将该字符串加载到web视图中。[_webView加载loadHTMLString:strDescription description nil:nil];// set string to web视图
要增加Web视图的动态高度:
- (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);
}发布于 2016-01-14 10:52:17
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];https://stackoverflow.com/questions/34787402
复制相似问题