<!--
{
  "availability" : [
    "macOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/windowResizeAnchor(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE18windowResizeAnchoryQrAA9UnitPointVSgF"
  },
  "title" : "windowResizeAnchor(_:)"
}
-->

# windowResizeAnchor(_:)

Sets the window anchor point used when the size of the view
changes such that the window must resize.

```
nonisolated func windowResizeAnchor(_ anchor: UnitPoint?) -> some View
```

## Parameters

`anchor`

The window point fixed under programmatic size
changes caused by the content size of the window changing.
Defaults to a system defined value when `nil`.

## Return Value

A view whose scene resizes on `anchor`.

## Discussion

In SwiftUI life cycle apps, this modifier can be used to control how
a window anchors when animating: drive window animations by changing
the size of a view in a way that causes the window size to change. Note
that if the window size is decreasing and an animation is desired, it
is often necessary to (temporarily, if desired) set the
[`windowResizability(_:)`](/documentation/SwiftUI/Scene/windowResizability(_:)) to [`contentSize`](/documentation/SwiftUI/WindowResizability/contentSize).

```
struct Scratchpad: App {
    var body: some Scene {
        WindowGroup {
            HeightResizingExample()
        }
        .windowResizability(.contentSize)
    }
}

struct HeightResizingExample: View {
    @State private var height: CGFloat = 300

    var body: some View {
        ZStack(alignment: .topLeading) {
            Color.red
                .overlay {
                    Text("Tap to toggle")
                        .foregroundStyle(.white)
                }
        }
        .onTapGesture {
            withAnimation(.easeInOut) {
                height = height == 300 ? 700 : 300
            }
        }
        .frame(width: 250, height: height)
        .windowResizeAnchor(.top)
    }
}
```

The default anchor varies by scene type and is used when `anchor` is
nil. Generally, it resolves to the `.topLeading` corner.

> Note: Animated window resizes are only supported in SwiftUI
> app-lifecycle apps. However, the anchor point is respected in all cases.

> Note: When animating windows on macOS, it can be helpful to explicitly
> specify `.topLeading` to avoid pixel cracking between the hosting view
> and the hosting window.

---

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)