0
在iOS 7和8的UITextView中使用調整工作時出現問題。字符串在直接設置字符串或使用NSAttributedString時正常工作我手動構建,但根本不工作,當我從HTML生成NSAttributedString。使用從HTML構建的NSAttributedString在iOS7/8 UITextView中進行調整
下面的代碼將正確克恩文字:
self.textView.attributedText = [[NSAttributedString alloc] initWithString:@"Test"];
但下面不:
NSString *html = @"<html><head><style>\
body { font-size: 40px; text-rendering: optimizeLegibility; }\
</style></head>\
<body>Test</body></html>";
NSAttributedString *attrString = [[NSAttributedString alloc]
initWithData:[html dataUsingEncoding:NSUTF8StringEncoding]
options:@{
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)
}
documentAttributes:nil error:nil];
self.textView.attributedText = attrString;
我在做什麼錯?