我正在尝试创建一个跨越整个窗口的文本字段。目前它只能在水平轴上扩展以填充视图。我希望实现类似TextEdit中看到的效果。
以下是我的代码:
struct ContentView: View {
@State var contents: String = "Hello World\nThis is a test.";
var body: some View {
VStack() {
TextField("Notes", text: $contents)
.lineLimit(nil)
}
.frame(height: 600)
}
}
在SwiftUI中是否有可能实现这个功能,还是需要使用传统的AppKit组件?