【发布时间】:2019-04-29 08:48:59
【问题描述】:
我有一个WKWebView 在我看来
@IBOutlet weak var htmlWKWebView: WKWebView!
我想将背景颜色更改为红色。我试过了:
htmlWKWebView.wantsLayer = true
htmlWKWebView.layer?.masksToBounds = true
htmlWKWebView.layer?.isOpaque = false
htmlWKWebView.layer?.backgroundColor = NSColor.red.cgColor
没有任何效果。只有这个:
htmlWKWebView.setValue(false, forKey: "drawsBackground") 使背景透明。但是背景颜色没有设置
【问题讨论】: