Skip to content

Instantly share code, notes, and snippets.

@emma-k-alexandra
Created December 7, 2020 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emma-k-alexandra/84a4e95b9fa73e922f586edc3602a8fe to your computer and use it in GitHub Desktop.
Save emma-k-alexandra/84a4e95b9fa73e922f586edc3602a8fe to your computer and use it in GitHub Desktop.
struct ContentText: View {
private var splitText: [String]
let count: Int
init(_ text: String) {
self.splitText = text.split(separator: " ").map { "\($0) " }
if text.hasPrefix(" ") {
self.splitText = [" "] + self.splitText
}
self.count = splitText.count
}
var body: some View {
ForEach(self.splitText.indices) { index in
Text(splitText[index])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment