1

I'm trying to add a TextEditor to my project with a different background color. I'd like to just use the simple extension that's found in this post: Transparent Background for TextEditor in SwiftUI

The problem is this--when I paste it in, I get the following errors as seen below:

extension NSTextView { // Cannot find type 'NSTextView' in scope.
  open override var frame: CGRect {
    didSet {
      backgroundColor = .clear // Cannot find 'backgroundColor' in scope.
      drawsBackground = true // Cannot find 'drawsBackground' in scope.
    }
  }
}

I assumed NSTextView was a built-in Swift type because there's documentation here (https://developer.apple.com/documentation/appkit/nstextview). I'm importing SwiftUI and Foundation at the top of the file. I'm trying to compile on an iPhone target set to iOS 14.4 so this shouldd definitely be working, right? What am I missing?

nickcoding2
  • 142
  • 1
  • 8
  • 34

0 Answers0