I am reading lines from a text files and displaying those lines on a Text element.
I may have scientific notation elements in there like
10^12
10^9
etc...
I need to display that as
and these numbers are in the middle of phrases, like..
The universe has 10^12 bla bla bla
How can I do that?
I show no code because I am clueless on that one.
Thanks
This kind of things are much easier in SwiftUI, there is lots of ways for this job in SwiftUI one of them could be this down code:
struct ContentView: View {
@State var yourFirstText: String = "The universe has "
@State var yourLastText: String = " bla bla bla"
var body: some View {
Text(yourFirstText) + Text("10") + Text("12").font(Font.footnote).baselineOffset(6.0) + Text(yourLastText)
}
}
This would require the OP to manually parse the text
@LeoDabus, hi Leo, You mean like defining some Var's or function to take text or numbers? if it is so it can be done if you think it is necessary
I mean a regex to find the ranges and properly format the text. Not so simple
similar to this post How do you set a currency label to show smaller font size for cents