# RichText-iOS **Repository Path**: EnjoyCodeing/rich-text-i-os ## Basic Information - **Project Name**: RichText-iOS - **Description**: No description available - **Primary Language**: Objective-C - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-24 - **Last Updated**: 2020-12-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RichText-iOS ### iOS原生 采用系统提供的WKWebView 部分代码如下: ``` #import WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:webView]; [webView loadHTMLString:htmlStr baseURL:nil]; ``` 即初始化WKWebView,然后通过网络请求获取富文本的字符串htmlStr,用webview加载即可,在模拟器上字体偏小,通过字符串拼接加入适配代码,或者后端适配好也可。 目前使用的适配代码如下,将富文本的字符串与下面代码的 ***htmlContent*** 替换即可 ``` NSString * fit_rich_web(void) { #define __wvjb_js_func__(x) #x static NSString * html = @__wvjb_js_func__( htmlContent ); #undef __wvjb_js_func__ return html; }; ```