Questions tagged [geometryreader]

A container view that defines its content as a function of its own size and coordinate space. Returns a flexible preferred size to its parent layout.

It's a component of Apple's SwiftUI language.

Learn more from Apple's documentation

184 questions
0
votes
0 answers

The bottom of the ScrollView is not reachable

I fail to make the scroll view able to reach the bottom of its view. The canvas is made of drawings where the user can touch through captured coordinates. Touching the bottom of the view is impossible due to the fact that the scroll view immediately…
phbardon
  • 127
  • 9
0
votes
0 answers

GeometryReader gives bad dimensions inside sheet with 16.4.1

The code below appears to give bad dimensions for a brief period, and then gives the correct ones. This was not happening prior to 16.4.1, it just started happening. The print statement will show a height and width of 0, and then it prints again,…
Jack
  • 2,206
  • 3
  • 18
  • 25
0
votes
0 answers

Why GeometryProxy frame in global space rotates when the app has gone to background in iPad?

Using these code struct SwiftUIView: View { struct BodySizePreferenceKey: PreferenceKey { static var defaultValue: CGRect { .zero } static func reduce(value: inout CGRect, nextValue: () -> CGRect) {} } var body: some…
Oscar Yuandinata
  • 1,025
  • 1
  • 13
  • 31
0
votes
1 answer

GeometryReader returns different values for top level view on simulator vs phone (SE 2nd generation)

I've been trying to chase down problems in my swiftUI app with differences between simulator and my actual phone and I've boiled it down to this - even with a dirt simple 1 view app, GeometryReader is returning a different value on my phone than in…
Andrew Voelkel
  • 513
  • 4
  • 10
0
votes
0 answers

Why is the width of the background being squeezed with animation when I only applied the animation to the rocket object?

I've used the GeometryReader to give an animation effect on the rocket object, but the background keeps getting affected by it somehow. Also I think that's what's causing the rocket to lag while moving. How do I make the rocket go out of the screen…
0
votes
2 answers

Swifui: How to use GeometryReader to be able to scale this view to fit any size parent?

This nested ring UI works well but how can I code it so it scales whether its parent is very small or very large? import SwiftUI struct CustomGaugeStyleView: View { @State private var innerRingFill = 6.5 var body: some View { …
GarySabo
  • 5,806
  • 5
  • 49
  • 124
0
votes
1 answer

How to Detect When User Reaches Bottom of the Screen and Trigger a Function in SwiftUI

What is the best way to detect when a user has scrolled to the bottom of the screen and trigger a specific function in SwiftUI? var body: some View { NavigationView { VStack { ZStack { Text("Pokedex") …
0
votes
1 answer

Cannot convert value type '()' to expected argument type '(() -> Void)?' error SwiftUI

I am trying to get the height of an item im creating by setting a geometry reader, then adding an .opAppear on an empty ZStack which pulls the height of the geo reader. struct MyView: View { @State private var height: CGFloat = 0 var body:…
0
votes
0 answers

How is GeometryReader wrapping ContentView affecting environmentObject assigned to that view?

I have added .environmentObject(AuthViewModel()) to ContentView which is also wrapped inside geometryReader inside struct conforming to App called MyApp. Exactly like it's reccomended in this answer https://stackoverflow.com/a/71970454/14743849…
Dzondzula
  • 1
  • 1
0
votes
0 answers

GeometryReader sometimes gives wrong .global frame origin for Map annotations

Test setup: I have a View that displays modally a Map with annotations: struct Annotation: Identifiable { let id = UUID() let name: String let coordinate: CLLocationCoordinate2D } struct MapViewSWUI: View { @Binding var…
Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116
0
votes
0 answers

SwiftUI get scrolling progress with Geometry Reader

im getting problem to make updates on my view by changing scroll progress. As example let's take case when user start scrolling view, and after value >= 50, subview makes offset by Y to 10. Animation works, but im getting message on my…
George Heints
  • 1,303
  • 3
  • 20
  • 37
0
votes
0 answers

How to set SwiftUI ScrollView position via CGPoint

I have this view where I'd like to insert an image inside a scroll view so when the user zooms in they can scroll through the zoomed in photo, however, I'd like to add a double tap functionality which zooms in and sets the position of the picture…
Nathan
  • 1,393
  • 1
  • 9
  • 40
0
votes
1 answer

Understanding frame idealHeight, maxHeight in GeometryReader

I have 3 buttons displayed in a GeometryReader. I am having trouble understanding how to correctly use .frame(), so that the buttons ideally have a set height (e.g. 60) when they are displayed on devices (iPhone 14) where the GeometryReader height…
Joseph
  • 691
  • 4
  • 18
0
votes
1 answer

Why do my SwiftUI gestures on a Map work only once?

Setup: I am converting an app from UIKit to SwiftUI. The app uses now instead of an MKMapView a SwiftUI Map. Unfortunately, not all features of an MKMapView are already provided by Apple for Map, e.g. dragging a map annotation and getting the…
Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116
0
votes
0 answers

How can I take a frame and divide its width by 2?

I am trying to set up a view that displays out a mathematical equation, with exponents being adjusted for size. I ran into an issue where after applying a scaleEffect to the item in the exponent, the frame of that view remained the same size,…