iOS HTML转字符串

2022-10-18  本文已影响0人  anny_4243
- (NSString *)htmlToString:(NSString *)htmlString {
   
    NSDictionary *options = @{ NSDocumentTypeDocumentAttribute :NSHTMLTextDocumentType,
    NSCharacterEncodingDocumentAttribute :@(NSUTF8StringEncoding) };
    NSData *data = [htmlString dataUsingEncoding:NSUTF8StringEncoding];
    NSAttributedString *string = [[NSAttributedString alloc] initWithData:data options:options documentAttributes:nil error:nil];
    return string.string;
}
上一篇 下一篇

猜你喜欢

热点阅读