Contents

width

The width of the measurement unit.

Declaration

var width: Measurement<UnitType>.FormatStyle.UnitWidth

Discussion

The width property specifies the display of the measurement unit. The possible values are abbreviated, narrow, and wide. The format style represents the unit in the shortest notation available.

The following example shows 100 degrees Fahrenheit in each width for the en_US locale.

let temperatureMeasurement = Measurement<UnitTemperature>(value: 100, unit: .fahrenheit)
temperatureMeasurement.formatted(.measurement(width: .wide)) // 100 degrees Fahrenheit
temperatureMeasurement.formatted(.measurement(width: .abbreviated)) // 100°F
temperatureMeasurement.formatted(.measurement(width: .narrow)) // 100°

See Also

Modifying a measurement format style