<!--
{
  "availability" : [
    "iOS: 27.2.0 -",
    "iPadOS: 27.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/nearbyInteractionOriginAnchor(session:isEnabled:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP019_NearbyInteraction_aB0E06nearbyE12OriginAnchor7session9isEnabledQrSo9NISessionC_SbtF"
  },
  "title" : "nearbyInteractionOriginAnchor(session:isEnabled:)"
}
-->

# nearbyInteractionOriginAnchor(session:isEnabled:)

Specifies this view as the reference body for the nearby interaction
session’s angle calculations.

```
nonisolated func nearbyInteractionOriginAnchor(session: NISession, isEnabled: Bool = true) -> some View
```

## Parameters

`session`

The session to specify this view as the body of.

`isEnabled`

Whether this view should be the session’s body.

## Discussion

```
@State private var session = NISession()

var body: some View {
    MyView()
        .nearbyInteractionOriginAnchor(session: session)
}
```

If more than one view specifies itself as the body of the same session,
the most recent one to do so becomes the body. Once a view stops being
the body, whether because it disappeared or because `isEnabled` became
`false`, the session has no body until some view specifies one again.

Use `isEnabled` to pick between views which are all on screen. For
example, an app might anchor angles to a compact indicator, except while
showing a full-screen finding experience, when it anchors to that
instead:

```
ZStack {
    CompactIndicator()
        .nearbyInteractionOriginAnchor(
            session: session, isEnabled: !isFinding)
    FindingView()
        .nearbyInteractionOriginAnchor(
            session: session, isEnabled: isFinding)
}
```

---

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)