经过长时间的研究,我发现NSAttributedString的initWithData方法闪烁了我的屏幕。这很奇怪。它从未发生在IOS 9之前。这是我的代码:
NSString *const str = [NSString stringWithFormat:@"<span style=\"font-family: %@; color:%@; font-size:%@\";>%@</span>", fontFace, _shop.currentTheme.options.itemDetailTextColor, fontSize,[entity description]];
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)};
//Screen flickers after the code below
NSAttributedString *const text = [[NSAttributedString alloc] initWithData:data options:options documentAttributes:nil error:nil];
itemDescriptionLabel.text = @"text"; //text;
我哪里错了?
更新:
如果我从选项中删除NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType,它可以正常工作。