Skip to content

Latest commit

 

History

History
21 lines (19 loc) · 396 Bytes

File metadata and controls

21 lines (19 loc) · 396 Bytes

如何设置可编辑文本 TextEditor 背景颜色?

extension NSTextView {
    open override var frame: CGRect {
        didSet {
            backgroundColor = .clear
            drawsBackground = true
        }
    }
}

struct ContentView: View {
    @State var text = ""
    var body: some View {
        TextEditor(text: $text)
            .background(Color.red)
    }
}