html5 请求的URL转成 OC可用属性字符串显示

时间:2022-02-20 22:22:02

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:helpUrlStr]];

NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[string dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];

ruleTextView.attributedText = attributedString;