I am trying to display multiple Text(string) in a single sentence as below, but Its breaks the line.
struct DisplayView: View {
@State var stringList = [
"Yes, it only returns the first occurrence. Therefore, to fulfill our purpose, ",
"we need to construct a while loop to iterate all the occurrences of a given string within the receiver. A reference snippet will be like the following code block. ",
"Note that an offset is also added to reduce the length of range in each iteration. So, actually, the position of each loop is basically based on the upper bound of the previous iteration"
]
var body: some View {
VStack {
ForEach(0..<stringList.count) { index in
Text("\(stringList[index])")
}
}
}
}
Here the issue is after each Text, it breaks the line.
But It works like-
struct DisplayView: View {
@State var stringList = [
"Yes, it only returns the first occurrence. Therefore, to fulfill our purpose, ",
"we need to construct a while loop to iterate all the occurrences of a given string within the receiver. A reference snippet will be like the following code block. ",
"Note that an offset is also added to reduce the length of range in each iteration. So, actually, the position of each loop is basically based on the upper bound of the previous iteration"
]
var body: some View {
VStack {
Text("\(stringList[0])") + Text("\(stringList[1])") + Text("\(stringList[2])")
}
}
}
But the point is list contains any number of strings 1/4/6/10. It could be multiple.
I want output like this. All text should continue after the previous one ends.

Please help. Thanks in advance.
