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
1
vote
0 answers

How to access safeAreaInsets of another CoordinateSpace in SwiftUI

I'm trying to write a view extension with a ViewModifier that allows me to position any view in the CoordinateSpace of another. My code so far does work, except that it has alignment issues if one of the CoordinateSpaces has a safe area. I'm able to…
Marco Boerner
  • 1,243
  • 1
  • 11
  • 34
1
vote
1 answer

How to drag across Views in a LazyVGrid with GeometryReader?

I want to drag across rectangles in a grid and change their color. This code is almost working, but this is not always the right rectangle that reacts: it behaves rather randomly. Any hints? import SwiftUI struct ContentView: View { let data =…
1
vote
0 answers

Development for iOS 13 and 14 with SwiftUI

I have a version of my app that runs correctly with iOS 13, but since iOS 14 Apple seem to change the way GeometryReader works (see: iOS 14 has Changed (or broken?) SwiftUI GeometryReader). The problem is that now there are two different sets of…
RT.
  • 423
  • 3
  • 12
1
vote
0 answers

Best approach getting subviews to layout vertically in SwiftUI?

I'm having a hard time getting subviews to lay out correctly, especially the heights. I hate to hard code the subview heights but that is the only thing I can get to work. If I remove these frame(heights) from the subviews, the subviews overlap in…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
1
vote
1 answer

SwiftUI: Why is the height of proxy.safeAreaInsets.bottom equal to keyboardHeight?

So the safeAreaInset.bottom on the iPhone 11 Pro Max is 34.0, but when the keyboard is open, it changes the safeAreaInset.bottom to the height of the keyboard (346.0 points). Is there any way to access the safeAreaInset.bottom value (34.0) when the…
nickcoding
  • 305
  • 8
  • 35
1
vote
3 answers

SwiftUI Nested GeometryReader - Breaking UI

So I am trying to understand why my subview (TopView) is having weird resizing issues. Here is the sample import SwiftUI struct ContentView: View { @State var isInterfaceHidden: Bool = false var body: some View { VStack(spacing: 0,…
Oleg G.
  • 550
  • 5
  • 25
1
vote
0 answers

Hide Tabbar when clicking on Card with Geometry Reader in SwiftUI

I am using a custom Tabbar and implemented the same animation you can find on the App Store from iOS, when you click on a card in the Today's View. As soon as a card is expanded I would like to hide the Tabbar. Currently I am hiding it with a bool…
1
vote
1 answer

GeometryReader behaves oddly with an extracted view

In this example, the "hello" text is placed in the middle of the screen, as expected. struct ContentView: View { var body: some View { GeometryReader { geo in Text("hello") .background(Color.green) } …
thedp
  • 8,350
  • 16
  • 53
  • 95
1
vote
2 answers

Why is the body of a GeometryReader evaluated twice? Also first time with dimensions of zero?

I have a GeometryReader nested inside of a NavigationView. Inside the GeometryReader I am using the dimensions supplied by the GeometryProxy with an if-statement. In my project I stumbled over the fact, that the content inside the GeometryReader is…
DFox
  • 86
  • 8
1
vote
1 answer

GeometryReader make Text height wrong

Not for all texts, but for specific length of text GeometryReader decides that Text should contains two lines: public var body: some View { ZStack { if loading { Text(text) .foregroundColor(.clear) …
Konstantin.Efimenko
  • 1,242
  • 1
  • 14
  • 38
1
vote
1 answer

SwiftUI ScrollView, GeometryReader and Button = Weird Behaviour

For the past 2 hours, I have been trying to get a ScrollView of buttons to work, more specifically ScrollView of buttons that uses GeometryReader to determine its size. Additionally, all this is placed within a NavigationView. There was weird…
Chiah Soon
  • 507
  • 5
  • 18
1
vote
1 answer

Animation not working with combination of GeometryReader and NavigationView

I've got an animated Image which is sliding up and down, using the offset and a timer. This works totally fine until you combine a GeometryReader and a NavigationView. For both, NavView and GeoReader on their own, the animation is working as well.…
adelmachris
  • 332
  • 2
  • 13
0
votes
1 answer

How to apply height of GeometryReader frame?

So I use the GeometryReader to read the available width of a container. Then I calculate how large the buttons should be and that decides the true size. However the GeometryReader seem to not be aware of the size of its children. How should you tell…
Mark
  • 16,906
  • 20
  • 84
  • 117
0
votes
0 answers

Why does the first size of the GeometryReader's closure parameter in the .task modifier have a value of 0 and how can I fix it?

I'm creating an app that shows a list of items on the main screen, and images and details of the selected item in a DetailView. In order to minimize the memory usage of the image, I am downsampling the size value of the GeometryReader's closure…
idhun90
  • 19
  • 3
0
votes
1 answer

How can I implement a "Drag to resize" for an image in SwiftUI?

Consider having a screen like on the wireframe consisting of text, an image, and a sheet. When the sheet is dragged down, the image should grow vertically and go out of bounds. This already works to a certain extent, but the image only scales…
ammerzon
  • 998
  • 1
  • 13
  • 30