Fix web view compilation issues
This commit is contained in:
parent
b749cfe5f4
commit
4b8b29a657
@ -8,6 +8,11 @@
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
import WebKit
|
||||
#if os(iOS) || os(tvOS)
|
||||
import UIKit
|
||||
#else
|
||||
import AppKit
|
||||
#endif
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
typealias PlatformViewRepresentable = UIViewRepresentable
|
||||
@ -26,9 +31,18 @@ struct HTMLClockView: PlatformViewRepresentable {
|
||||
|
||||
private func createWebView() -> WKWebView {
|
||||
let webView = WKWebView()
|
||||
#if os(iOS) || os(tvOS)
|
||||
webView.isOpaque = false
|
||||
webView.backgroundColor = .clear
|
||||
webView.scrollView.isScrollEnabled = false
|
||||
#else
|
||||
webView.setValue(false, forKey: "drawsBackground")
|
||||
webView.isOpaque = false
|
||||
if let scrollView = webView.value(forKey: "scrollView") as? NSScrollView {
|
||||
scrollView.hasVerticalScroller = false
|
||||
scrollView.hasHorizontalScroller = false
|
||||
}
|
||||
#endif
|
||||
if let url = Bundle.main.url(forResource: "analog-clock", withExtension: "html") {
|
||||
webView.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user