Just figuring out how I can achieve multiple lines of text in a Text
. It seems like the Text
has the same default as UILabel
(one line), but I can't find any function which meets this criteria.
struct ContentView : View {
var body: some View {
VStack(alignment: .leading, spacing: 10) {
HStack {
Text("Avocado Toast").font(.system(size: 24))
}
// This Text does cut, and I wonder how I can achieve multiple rows
Text("Ingredients: Avocado, Almond Butter, Bread")
.font(.system(size: 20))
}
}
}
Edit
.lineLimit(X)
, did the trick. But is it possible to not set a specific amount, for instance. With just a 0?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…