Created
December 7, 2020 04:57
-
-
Save emma-k-alexandra/84a4e95b9fa73e922f586edc3602a8fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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