Displaying a character count next to each word in the list
I also want to add a number next to each word that indicates how many letters are in the word that the user has entered. Later, we will take this number from each word and add them together to get an average of how the user is doing in terms of the length of words they are entering.
We can put this number inside a circle, and luckily this is very easy, as Swift gives us system images of circles with numbers in them that are already created; all we have to do is call them up. So, back in ContentView
, then inside the List
view, let’s put the Text
view inside of an HStack
(so they are side by side), and add an Image
view for the number circle:
List(guessedWordsArray, id: \.self) { word in HStack { Image(systemName: ...