Nig*_*awk 5 xcode swift swiftui
如何在 SwiftUI 中制作具有某种风格的文本编辑器?似乎文本编辑器不能像文本字段那样可定制。
我怎样才能达到这样的结果(这里用户的文本是白色的)?
我的问题是如何在文本编辑器中将文本颜色设置为白色并设置背景颜色。
struct ContentView: View {
init() {
UITextView.appearance().backgroundColor = .clear // First, remove the UITextView's backgroundColor.
}
@State private var input = ""
var body: some View {
ZStack {
Color.blue.edgesIgnoringSafeArea(.all)
TextEditor(text: $input)
.font(.body)
.foregroundColor(.white) // Text color
.background(Color.blue) // TextEditor's Background Color
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5652 次 |
| 最近记录: |