文本标签未根据 ScrollView SwiftUI 中的字符串扩展
Text Label is not expanding according to string in ScrollView SwiftUI
我只是在滚动视图中添加了 TextLabel,但它仅显示在 1 行中。没有 scrollview 它在 Label
的全高下工作正常
struct UserDetailView: View {
var userObj:User?
var body: some View {
ScrollView {
VStack {
Text("Hi here is Erick jackson. We need to help you. We will help you. Anything new to learn from you. I am here for that reason.")
.background(Color.orange)
.multilineTextAlignment(.center)
.lineLimit(5)
}
}
.padding(.horizontal,30)
}
}
在 Text("Hi here is Erick Jackson....")
:
之后尝试 .fixedSize
修饰符
...
Text("Hi here is Erick jackson. We need to help you. We will help you. Anything new to learn from you. I am here for that reason.")
.fixedSize(horizontal: false, vertical: true)
.background(Color.orange)
...
struct UserDetailView: View {
var userObj:User?
var body: some View {
ScrollView {
VStack {
Text("Hi here is Erick jackson. We need to help you. We will help you. Anything new to learn from you. I am here for that reason.")
.background(Color.orange)
.multilineTextAlignment(.center)
.lineLimit(5)
}
}
.padding(.horizontal,30)
}
}
在 Text("Hi here is Erick Jackson....")
:
.fixedSize
修饰符
...
Text("Hi here is Erick jackson. We need to help you. We will help you. Anything new to learn from you. I am here for that reason.")
.fixedSize(horizontal: false, vertical: true)
.background(Color.orange)
...