Closed boherna closed 4 years ago
Seeing the same errors here:
I ran across the same issue, and I was able to trace it to this line:
Text(String(format: "%.2f", value))
If, instead, I use NumberFormatter
to generate a string from value
, Text
will take it just fine:
private static let numberFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2
return formatter
}()
...
var body: some View {
HStack {
Slider(value: $value, label: { Text(title) })
Text(sliderDisplayValue)
}
.disabled(!isEnabled)
.addingInfoButton(title: title, description: description)
}
var sliderDisplayValue: String {
Self.numberFormatter.string(for: value) ?? ""
}
Hi, any ideas why I'm getting these errors. Thanks.