Tools: [SUI] GeometryReader

Tools: [SUI] GeometryReader

Source: Dev.to

Bibliografía GeometryReader define su contenido como una función del tamaño que tiene disponible. Este recibe un objeto GeometryProxy que tiene un método frame(in:) y unas propiedades size y safeAreaInset que informan del tamaño del contenedor. Es posible que necesite saber la posición del GeometryReader con respecto a otro contenedor externo, para lo que se usa frame(in:). Este modificador recibe como argumento global, local o named(_:). Este último permite relacionar el GeometryReader con un contenedor específico, al aplicar coordinateSpace(_:) al contenedor de interés. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK: VStack { GeometryReader { geometryProxy in let distanceFromTop = geometryProxy.frame(in: "container").origin.y Text("This view is \(distanceFromTop) points from the top of the VStack") } .padding() } .coordinateSpace(.named("container")) Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: VStack { GeometryReader { geometryProxy in let distanceFromTop = geometryProxy.frame(in: "container").origin.y Text("This view is \(distanceFromTop) points from the top of the VStack") } .padding() } .coordinateSpace(.named("container")) CODE_BLOCK: VStack { GeometryReader { geometryProxy in let distanceFromTop = geometryProxy.frame(in: "container").origin.y Text("This view is \(distanceFromTop) points from the top of the VStack") } .padding() } .coordinateSpace(.named("container")) - Gauchat, J. D. (2024). SwiftUI for Masterminds: How to take advantage of Swift and SwiftUI to create insanely great apps for iPhones, iPads, and Macs (5a ed.). John D Gauchat.