跳转至
Structure

GeometryProxy

A proxy that encapsulates the container's frame and safe area insets, used by GeometryReader.

Declaration

struct GeometryProxy

Overview

For example, to create a new GeometryProxy for use in a GeometryReader:

struct ExampleView: View {
    var body: some View {
        GeometryReader { (proxy: GeometryProxy) in
            Color.green
                .frame(
                    width: proxy.size.width / 2,
                    height: proxy.size.height / 2
                )
        }
    }
}
A view containing a GeometryReader with a GeometryProxy, green color, and frame height and width defined by the proxy; the view results in a green rectangle in the upper left corner of the frame.

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 6.0+

Topics


Instance Property

safeAreaInsets The safe area inset of the container view.

size The size of the container view.


Subscript

subscript(anchor:) Converts the anchor to a value in the coordinate space of the target view.


Instance Method

frame(in:) Returns the parent GeometryReader's frame, converted to a defined CoordinateSpace.