我正在使用 SwiftUI 为 macOS 创建基于文档的应用程序。
是否有用于显示 TextEditor 行号的内置样式方法?
struct ContentView: View {
@Binding var document: AppDocument
var body: some View {
TextEditor(text: $document.text) // I removed a few irrelevant options.
.disableAutocorrection(true)
.font(.system(size: 12, design: .monospaced))
}
}
最佳答案
不,TextEditor
没有显示行号的方法。
您可以通过这两个链接自行确认。
文本编辑器
可以显示和编辑长格式文本的 View 。
https://developer.apple.com/documentation/swiftui/texteditor
外观和行为
配置 View 的文本、控件和其他内容。
https://developer.apple.com/documentation/swiftui/view-appearance-and-behavior
关于swift - 在 macOS SwiftUI TextEditor 中显示行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66508315/