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
}
}
}
推荐阅读
- acumatica - ARBalance 更新后的 Acumatica 发布操作
- javascript - 仅从电子邮件地址数组中获取电子邮件地址域名
- prometheus - avg_over_time(rate()) 相对于 rate() 本身的优势?
- svn - 使用 SVN 创建新分支并移动未提交的工作副本更改
- reporting-services - 使用通配符参数的 SSRS 字体颜色
- sql - SQL Server - 我可以让 IDENTITY_INSERT 永远为 ON 吗?
- regex - htaccess 重定向和别名根文件夹
- python - 无法使用 librosa 加载音频文件
- java - 如何在Java中将“2020-08-07T16:07:13.337248Z”中的UTC日期字符串转换为“MM-dd-yyyy hh:mm”
- jquery - 在每个循环 Jquery 中添加