[英]Top alignment/position of text in SwiftUI
您可以在 Text View 之后使用Spacer()
将其向上推。
struct ContentView: View {
var body: some View {
VStack {
Text("Hello World!")
Spacer()
}
}
}
我试图添加 alignment 属性,但很少或没有成功。
或者,您可以使用带有 .top .top
的frame
:
struct ContentView: View {
var body: some View {
Text("Hello World!")
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.