本文介绍了文本不会被包裹在快速的UI中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
即使在设置.lineLimit(nil)
之后,文本也不会被换行.
Even After setting the .lineLimit(nil)
the text doesn't get wrapped.
var body: some View {
VStack(alignment: .center) {
Text("SwiftUI is a modern way to declare user interfaces for any Apple platform. ")
.font(.title)
.color(.red)
.lineLimit(nil)
Text("Create beautiful, dynamic apps faster than ever before.")
.font(.system(size: 20))
.lineLimit(nil)
}.padding(EdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10))
}
推荐答案
尝试将第二个文本的lineLimit
更改为数字而不是nil:
Try changing the second Text's lineLimit
to a number instead of nil:
VStack(alignment: .leading) {
Text("SwiftUI is a modern way to declare user interfaces for any Apple platform. ")
.font(.title)
.color(.red)
.lineLimit(nil)
Text("Create beautiful, dynamic apps faster than ever before.")
.font(.system(size: 20))
.lineLimit(2)
}.padding(EdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10))
结果:
这篇关于文本不会被包裹在快速的UI中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!