ios端简单改变webView的黑白夜模式
extension HTController:WKUIDelegate, WKNavigationDelegate,WKScriptMessageHandler {
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
if message.name == "setTitle" {
let body = message.body
print(NSLocalizedString("点击了这个方法\(body)", comment: ""))
}
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
let colorStyle:String = kUserDefaults.string(forKey: "ColorStyle")!
if colorStyle != "day" {
webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.background='#333333'", completionHandler: nil)
webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'white'", completionHandler: nil)
webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '300%", completionHandler: nil)
}else{
webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.background='#ffffff'", completionHandler: nil)
webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'black'", completionHandler: nil)
webView.evaluateJavaScript("document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '300%", completionHandler: nil)
}
}
}
最新文章
- UWP开发之Mvvmlight实践四:{x:bind}和{Binding}区别详解
- Code::Blocks配置GTK+2和GTK+3
- throw er; // Unhandled 'error' event
- axure rp pro 7.0(页面原型工具)
- PHP框架_Smarty
- iOS开发之XMPP即时通讯简单实现
- IDE编程环境
- JavaScript是如何面向对象的
- 2019-04-09 SpringBoot+Druid+MyBatis+Atomikos 的多数据源配置
- Mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server
- django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call
- shell关于变量的操作
- MPD软件工作坊北京站:技术创新与研发效率带来的前沿思考
- 读书笔记(04) - 错误监控 - JavaScript高级程序设计
- SQLSERVER中的元数据锁
- JAVA识别字符串是数字(英文)还是汉字,web页面进行字符截断的帮助类
- <;input type=";date";>;设置默认当前日期
- C语言:写一函数,将两个字符串中的元音字母复制到另一个字符串,然后输出
- laravel 使用 session
- Open XML操作Excel导入数据
热门文章
- java.io.IOException: java.io.FileNotFoundException: /tmp/tomcat.2457258178644046891.8080/work/Tomcat/localhost/innovate-admin/C:/up/154884318438733213952/sys-error.log (没有那个文件或目录)
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 显示代码:电脑程序输出: Sample output
- Python中self的用法
- vue-router重定向redirect
- 设计模式课程 设计模式精讲 16-2,3 代理模式Coding-静态代理-1
- UniGui安装(01)
- VS2010如何在同一个解决方案下建立多个项目以及切换运行不同项目
- Kafka源码系列之源码分析zookeeper在kafka的作用
- jgrid异步数据加载
- RabbitMq学习笔记——概念