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
2
votes
2 answers

SWiftUI anchorPreference inside List

I'm using anchorPreferences to set the height of GeometryReader to fit the height of its content. The issue I'm experiencing is, after scrolling up and down the List a few times, the app freezes, the design gets messy, and I get the following…
Aнгел
  • 1,361
  • 3
  • 17
  • 32
2
votes
2 answers

GeometryReader seems to change layout of view that is using its size data. How can I avoid this?

I would like my icon image to be 1/3 the width of total screen availability. My code is as follows: var body: some View { GeometryReader { geometry in Image(systemName: "square.dashed").resizable() …
2
votes
1 answer

ScrollView doesn't scroll properly (bounces) in combination with Geometry Reader

I already reviewed the answer here (ScrollView Doesn't Scroll with Geometry Reader as Child) which is I guess pretty similar but I wasn't able to figure it out. My Goal is to show the images equally sized (quadratic). Here's my View: struct…
SwiftUIRookie
  • 591
  • 7
  • 16
2
votes
0 answers

SwiftUI iOS14 GeometryReader Invalid frame dimension

My GeometryReader was working fine in iOS13 but now in iOS14 i get a thread issue. "Invalid frame dimension (negative or non-finite)." I printed the size that the reader should give back and it looked fine. The app is still basically working, but…
C. Maier
  • 39
  • 6
2
votes
1 answer

SwiftUI - Transition Animations not working in GeoReader?

I have code like this: VStack{ if (DeleteScreen.sharedInstance.postDelete){ VStack{ GeometryReader{_ in DeletePostAlert() …
Evan
  • 1,892
  • 2
  • 19
  • 40
2
votes
1 answer

Detecting tap gesture on the background of a GeometryReader SwiftUI

I have a main view, and, within that view I have a little pop-up menu that is within a GeometryReader, like this: if (self.show){ GeometryReader{_ in Menu() …
Evan
  • 1,892
  • 2
  • 19
  • 40
2
votes
1 answer

How to limit size of GeometryReader inside a VStack

I would like to stop GeometryReader from interfering with my layout in a VStack but I'm not sure what the correct approach is. Given the example of a simple graph with a title and caption: struct Graph: View { var body: some View { …
Craigt
  • 3,418
  • 6
  • 40
  • 56
2
votes
1 answer

ScrollView is not working correctly with GeometryReader

I have some issues with the scrollview and GeometryReader. I want to have a list of items under an image. And each item should have the following width and height: ((width of the entire screen - leading padding - trailing padding) / 2). I have…
stefOCDP
  • 803
  • 2
  • 12
  • 20
2
votes
1 answer

How to get frames (size and coordinates) for different views in SwiftUI?

I need to get frames for multiple views inside a VStack. I think using the GeometryReader but it returns the necessary parameters only for the parent. How can I get these parameters for each view on the screenshot below?
yuraist
  • 121
  • 2
  • 9
2
votes
0 answers

How to dynamically offset a cropped Image in SwiftUI?

What I like to achieve with SwiftUI is that a certain part of in image (a x,y point provided by the content management system) is always visible, also in cases the image needs to be resized and cropped to fit the layout. Visual example of what I…
Markus
  • 21
  • 2
2
votes
1 answer

SwiftUI GeometryReader makes its content loaded twice

How are you doing? Please consider the following code: struct ContentView: View { var body: some View { NavigationView { GeometryReader { geometry in ZStack(alignment: .leading) { ViewOne() …
UIChris
  • 601
  • 2
  • 6
  • 19
2
votes
1 answer

SwiftUI - Button doesn't work at the top left of the view

I am new in SwiftUI and I am having an issue with my "hamburger" menu. Basically I have created 2 views for the Home page: Home view and Home Side Menu view. My main goal is to put the "hamburger" button at the top left of the view and open the…
Sofia
  • 23
  • 1
  • 4
2
votes
2 answers

SwiftUI - ScrollView not scrolling all the way to the bottom

I having problems with getting my scroll view to scroll all the way to the bottom. What's odd is that when it's populated with one set of data, it doesn't have this issue, however, in the other data set it gets to the last item and I can't scroll to…
Jason Tremain
  • 1,259
  • 3
  • 20
  • 35
2
votes
1 answer

SwiftUI layout with GeometryReader inside ScrollView

I'm trying to create a scrollable grid of items. I create a custom view called GridView which uses GeometryReader to divide the space into columns and rows in HStacks and VStacks. But for some reason, its size shrinks to almost nothing when inside a…
Rob N
  • 15,024
  • 17
  • 92
  • 165
1
vote
0 answers

SwiftUI GeometryReader not working properly in sheet

I am trying to fit the size of a sheet to its content. There is another question on StackOverflow addressing this topic. However the problem is that GeometryReader does not seem to work properly when used inside a sheet, combined with the usage of…
Codey
  • 1,131
  • 2
  • 15
  • 34