<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/PhysicalMetric",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14PhysicalMetricV"
  },
  "title" : "PhysicalMetric"
}
-->

# PhysicalMetric

Provides access to a value in points that corresponds to the specified
physical measurement.

```
@propertyWrapper @frozen struct PhysicalMetric<Value>
```

## Overview

Use this property wrapper inside a [`View`](/documentation/SwiftUI/View) or a type that inherits a `View`’s
environment, like a [`ViewModifier`](/documentation/SwiftUI/ViewModifier). Its value will be the equivalent in points
of the physical measurement of length you specify.

For example, to have a variable that contains the amount of points corresponding
to one meter, you can do the following:

```swift
struct MyView: View {
    @PhysicalMetric(from: .meters)
    var twoAndAHalfMeters = 2.5
    …
}
```

Using this wrapper for a property of a type not associated with a scene’s view
contents, like an  [`App`](/documentation/SwiftUI/App) or a [`Scene`](/documentation/SwiftUI/Scene), is unsupported.

## Compensating for World Scaling

Starting with apps built against the visionOS 2.0 SDK, the default behavior of
`PhysicalMetric` is to produce values that match the distances used by
`RealityView`s in the same scene, by scaling its returned values to match
the world scaling of the current scene. Previously, the values were not scaled,
and they were suitable for measuring distances and lengths within the user’s
surroundings, outside of any scene. Unscaled values could produce unexpected
behavior if used in conjunction with `RealityView`s within the scene.

To modify the behavior of `PhysicalMetric` and obtain unscaled values,
use the [`transformEnvironment(_:transform:)`](/documentation/SwiftUI/View/transformEnvironment(_:transform:)) modifier,
transforming the [`physicalMetrics`](/documentation/SwiftUI/EnvironmentValues/physicalMetrics) key path,
to edit the converter used by `PhysicalMetric` within the modified views
to use a new [`WorldScalingCompensation`](/documentation/SwiftUI/WorldScalingCompensation) mode. For example:

```swift
struct RulerView: View {
    @PhysicalMetric(from: .meters)
    var oneMeter = 1

    var body: some View {
        /* implement a size-accurate ruler */
    }
}

struct ContentView: View {
    var body: some View {
        RulerView()
            .transformEnvironment(\.physicalMetrics) { metrics in
                metrics = metrics.worldScalingCompensation(.unscaled)
            }
    }
}
```

> SeeAlso: ``doc://com.apple.SwiftUI/documentation/SwiftUI/PhysicalMetricsConverter``

> SeeAlso: ``doc://com.apple.SwiftUI/documentation/SwiftUI/WorldScalingCompensation``

## Topics

### Creating a metric

[`init(wrappedValue:from:)`](/documentation/SwiftUI/PhysicalMetric/init(wrappedValue:from:))

Creates a value that maps the specified point, whose dimensions are specified
in physical length measurements in the given unit, to the corresponding value in points in the
associated scene.

### Getting the value

[`wrappedValue`](/documentation/SwiftUI/PhysicalMetric/wrappedValue)

A value in points in the coordinate system of the associated scene.



---

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)