numberFormatStyle
The formatting of the measurement value.
Declaration
var numberFormatStyle: FloatingPointFormatStyle<Double>?Discussion
The numberFormat property specifies the formatting of the measurement value. You can customize the precision, grouping, and rounding mode of the measurement by creating a numeric number format style.
The following example shows a customized measurement format style that includes two decimal numbers and excludes separators:
let volume = Measurement<UnitVolume>(value: 2300, unit: .milliliters)
volume.formatted(.measurement(width: .abbreviated,
usage: .asProvided,
numberFormatStyle: .number
.precision(.fractionLength(2))
.grouping(.never))) // "2300.00 mL"