<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FormatStyle/measurement(width:usage:hidesScaleName:numberFormatStyle:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation11FormatStylePAAE11measurement5width5usage14hidesScaleName06numberbC0AA11MeasurementVAASo11NSDimensionCRbzrlEABVySo17NSUnitTemperatureC_GAM9UnitWidthVyAO__G_AA0kbO5UsageVyAOGSbAA013FloatingPointbC0VySdGSgtAPRszrlFZ"
  },
  "title" : "measurement(width:usage:hidesScaleName:numberFormatStyle:)"
}
-->

# measurement(width:usage:hidesScaleName:numberFormatStyle:)

Returns a format style to format temperature units.

```
static func measurement(width: Measurement<UnitTemperature>.FormatStyle.UnitWidth = .abbreviated, usage: MeasurementFormatUnitUsage<UnitTemperature> = .general, hidesScaleName: Bool = false, numberFormatStyle: FloatingPointFormatStyle<Double>? = nil) -> Self where Self == Measurement<UnitTemperature>.FormatStyle
```

## Parameters

`width`

The width — such as full names or abbreviations — with which to present units.

`usage`

The contextual usage of the measurement unit, such as whether a temperature applies to a person or to the weather.

`hidesScaleName`

A Boolean value that directs the formatter to hide the name of the scale (Kelvin, degrees Celsius, or degrees Fahrenheit). Defaults to `false`.

`numberFormatStyle`

The format style with which to format the numeric part of the temperature.

## Return Value

A format style that formats measurements according to the given parameters.

## Discussion

Use this static method when the call point allows the use of [`Measurement.FormatStyle`](/documentation/Foundation/Measurement/FormatStyle) and the value type is `Measurement<UnitTemperature>`. You typically do this when calling the [`formatted(_:)`](/documentation/Foundation/Measurement/formatted(_:)) method of [`Measurement`](/documentation/Foundation/Measurement).

The following example creates an array of [`Measurement`](/documentation/Foundation/Measurement) values that represent body temperatures from a human patient. It then uses [`formatted(_:)`](/documentation/Foundation/Measurement/formatted(_:)) and the format style provided by this method to format the distances. The style specifies the [`person`](/documentation/Foundation/MeasurementFormatUnitUsage/person-4ifk7) usage to clarify that the temperatures refer to a person’s body temperature, as opposed to other uses like weather.

```swift
let rawTemparatures: [Double] = [36.4, 36.6, 37.0, 36.9, 36.7]
let temperatures = rawTemparatures.map { Measurement(value: $0, unit: UnitTemperature.celsius) }
let formattedTemperatures = temperatures.map { $0.formatted(
    .measurement(width: .abbreviated,
                 usage: .person,
                 hidesScaleName: false,
                 numberFormatStyle: .number)) } // ["36.4°C", "36.6°C", "37°C", "36.9°C", "36.7°C"]
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)