We would like to show jump height as 31 cm instead of 0.3 m, but formatter insists on 0.3m when we select option natural scale and use metric system:
var measurement = Measurement(value: 0.31, unit: UnitLength.meters)
formatter.unitOptions = [.naturalScale]
print(formatter.string(from: measurement))
same output with cm:
var measurement = Measurement(value: 31, unit: UnitLength.centimeters)
formatter.unitOptions = [.naturalScale]
print(formatter.string(from: measurement))
and without natural scale we get "0 km"
How we can configure formatter to display 31 cm?
Post
Replies
Boosts
Views
Activity
import SwiftUI
struct Alerts: View {
var body: some View {
Text("Where is the Alert?")
.alert(isPresented: .constant(true)) {
Alert(title: Text("Hello"),
message: Text("World"))
}
}
}
struct Alerts_Previews: PreviewProvider {
static var previews: some View {
Alerts()
}
}
does not show the alert, only shows text.
Live preview fails to start with message:
The application "App" may have exited. Try again or make another change to your code.
We also use previews for test to render previews for snapshots and we are unable to render Alerts.