I am trying to create a background text color that tracks to the width of each line of multi line text. See image below:
I have only been able to get a basic box background color using .background(Color.black) it gives a background to the entire text box. The desired effect is to give the background only to the end of each line of text.
I only know how to solve this in PHP/CSS. First, put the text into a variable. then replace all spaces through the div tags. then add the CSS for the div. and that's it:
!Important! be sure that at the beginning and the is no space and in the middle of the text are not enter space
Here my code example:
But I'm sure that the same method is possible with SwiftUI by just looping the text and replace the space
--> just search for text-replacing in SwiftUI and you will find what you need