Skip to main content
.coordinateSpace(name: string)
name
string
required
A unique name for this coordinate space. Other components can reference this name in GeometryProxy.frame() to get their position relative to this component.

Support

Usage

Named scroll view coordinate space

ScrollView([
    VStack(items.map((item) =>
        Text(item.name)
            .visualEffect((builder, proxy) =>
                builder.opacity(
                    proxy.frame("scroll").minY > 0 ? 1 : 0.3
                )
            )
    ))
])
    .coordinateSpace("scroll")

Track position relative to a container

VStack([
    GeometryReader((proxy) =>
        Text("Y: " + String(proxy.frame("container").minY))
    )
])
    .coordinateSpace("container")

See Also