Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set dark/light for web content
private func setMode(_ isDark: Bool) {
let mode = isDark ? "add" : "remove"
let script = "document.body.classList.\(mode)(\"dark\");"
webView.evaluateJavaScript(script) { result, error in
if let err = error {
os_log("%{public}s", log: logger, type: .error, "js error: \(err).")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.