안녕하세요 저는 NSMutableAttributedString에 htmlString 변환하고 객관적인 C. 새로운 오전. 하지만 NSMutableAttributedString의 글꼴 크기를 변경하면 내 텍스트에서 굵은 글꼴이 제거되므로 친절하게도 모든 솔루션을 제공합니다.굵게 서식을 제거하지 않고 NSMutableAttributedString의 글꼴 크기를 변경합니다.
내 코드 :
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil ];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// overView.font = [UIFont systemFontOfSize:16];
[attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0, attributedString.length)];
}
else{
// overView.font = [UIFont systemFontOfSize:12];
[attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, attributedString.length)];
}
overView.attributedText = (NSAttributedString *)attributedString;
어떤 도움 덕분에 감상 할 수있다.
은 **이 **, 당신은 할 수 없습니다. 'boldSystemFontOfSize' 메소드도 있습니다. – vadian
@vadian 모든 문자열을 굵게 표시합니다. – Furqan
물론 범위가 전체 문자열에 지정 되었기 때문에. 부분 문자열이 필요하면 범위를 조정해야합니다. – vadian