在使用第三方字体
仅限本地资源
Dynamic Load Fonts From Bundle
使用可以动态加载字体到中
Loading iOS fonts dynamically
UIWebview
甚至可以使用Inject CSS改变远程网页的字体
You can load a font this way at any time during your app’s execution, and it immediately becomes available inand(via regularCSSdeclarations, norequired) just as if it had been declared in.
WKWebView
能使用来加载网页和自定义CSS
Inject CSS方法对无效,不能加载CSS中定义的字体。
故不能使用该方法改变远程网页的字体,所以这个解决方案使用的场景有限
把网页(远程或本地)转化成,在中插入
然后通过来加载网页
重点来了path1,path2,path3
path1就是相对于path2的路径
如 path2 = “Frameworks/xxx.framework/xxx.bundle”
css = “Frameworks/xxx.framework/xxx.bundle/CSS/css_name.css”
path1 = “CSS/css_name.css”
path3就是相对于path1的路径
如 font 存在于路径 “Frameworks/xxx.framework/xxx.bundle/Fonts/xxx.otf”
path3 = “../Fonts/xxx.otf”
领取专属 10元无门槛券
私享最新 技术干货