I hit the same problem as the OP (and I'm considering posting my code as open source in a bit). While editing text fields embedded in a List, the background turns white behind the text field (unexpected and unfortunate, when the background of my list and the text fields are a color other than white).
But to get OP to jump over the problem, add this:
extension NSTextView {
open override var frame: CGRect {
didSet {
backgroundColor = .clear
drawsBackground = true
}
}
}
The problem with adding this to your SwiftUI code is that it will set the backgroundColor to clear for ALL other AppKit NSTextViews. You can't set a private access modifier on this extension which has an open var. So this problem is still an open issue for me.
edit: I'm wondering if the OP has the same application setup as me -- where I am embedding a SwiftUI view via a NSHostingView inside a regular NSWindow alongside other (non-SwiftUI) NSViews. When it's a pure SwiftUI app, I do not see this problem when editing text fields.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: