---
title: "windowResizeAnchor(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/windowresizeanchor(_:)"
---

# windowResizeAnchor(_:)

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

## Declaration

```swift
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

Return Value A view whose scene resizes on anchor.

## Discussion

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(_:) to 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.

## See Also

### Window behaviors

- [windowDismissBehavior(_:)](swiftui/view/windowdismissbehavior(_:).md)
- [windowFullScreenBehavior(_:)](swiftui/view/windowfullscreenbehavior(_:).md)
- [windowToolbarFullScreenVisibility(_:)](swiftui/view/windowtoolbarfullscreenvisibility(_:).md)
- [windowMinimizeBehavior(_:)](swiftui/view/windowminimizebehavior(_:).md)
- [windowResizeBehavior(_:)](swiftui/view/windowresizebehavior(_:).md)
- [preferredWindowClippingMargins(_:_:)](swiftui/view/preferredwindowclippingmargins(_:_:).md)
