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

110 questions
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,156
  • 1
  • 8
  • 21
2
votes
1 answer

Is there a way to define the width of my SwiftUI Image to be relative to screen size using Geometry Reader?

I am working through a sample app to familiarize myself with Swift and SwiftUI and am wanting to combine the ideas of composite layouts using custom views and GeometryReader to determine the screen-size of the device. The page I'm trying to build…
Mdank
  • 63
  • 4
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
  • 2,778
  • 4
  • 34
  • 46
2
votes
2 answers

SwiftUI erroneous vertical alignment of overlay when using GeometryReader

I have an overlay view that I want to appear hugging the top edge of its parent view (aligned vertically to top not center, see snapshot B) and have the ability to semi-hide it when tapped (move it up so that it doesn't obscure its parent view, and…
andrewz
  • 3,682
  • 3
  • 37
  • 57
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? Layout I need to get frames…
yuraist
  • 31
  • 6
2
votes
1 answer

How do I get my UIView to correctly size for its content in SwiftUI?

I want to use the awesome MultiSegmentPicker written by Yonat Sharon in my SwiftUI View. https://github.com/yonat/MultiSelectSegmentedControl However, I don't fully understand the interaction between the UIViewRepresentable View and my SwiftUI View.…
Mozahler
  • 3,643
  • 6
  • 24
  • 42
2
votes
1 answer

why is VStack not working in GeometryReader with scrollview?

My scrollview with vStack worked (in AppleTV - i did not test in iOS) without GeometryReader. Then i added the geometryreader and the VStack "collapses" like a ZStack. What can i do to solve this? (and yes, i need the geometryreader ;)) struct…
Chris
  • 4,934
  • 3
  • 12
  • 32
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
  • 18
1
vote
1 answer

SwiftUI: How can I get the frame of a view in a dynamic List or LazyVStack

I would like to get the frame of a view in a LazyVStack. The LazyVStack embedded in a ScrollView displays chat messages (Text and Images). Because the content is dynamically sized I am not able to use a GeometryReader Proxy. Putting a…
alionthego
  • 5,738
  • 7
  • 38
  • 74
1
vote
1 answer

How to cut an image into 2 using SwiftUI

I have an image like this I'd like to split it into 2 pieces across the center using SwiftUI. Leaving me with 2 separate images that I can access. However I can't figure out how to split the original into a top and bottom piece. The two pieces must…
M. Hig
  • 71
  • 10
1
vote
1 answer

How can I remove the animation from geometryReader?

I just want to remove the animation on the offset. Is something like this possible ? If you do not remove that animation, when I scroll as in the image below, the visual animation will go into effect and a hitch occurs. remove the animation on the…
Ufuk Köşker
  • 389
  • 2
  • 8
1
vote
0 answers

Image flickering while geometryReader swipes

The picture flickers when swiping when I use NavigationLink. (Section One) I solved the image flickers problem. I used a different NavigationLink function. (Section Two) the problems don't stop there. When the navigation is running, the image shifts…
1
vote
0 answers

SwiftUI: Get height of content inside of ScrollView to update frame

I need to update the height of my ScrollView depending on the content height inside of it. I have a working carousel below: struct PostsPaging: View where Content: View { @Binding var index: Int let maxIndex: Int let content: () ->…
Ryan
  • 123
  • 1
  • 13
1
vote
0 answers

SwiftUI Crash when keyboard is triggered

I've built an app in SwiftUI and I'm encountering an issue that I'm not able to resolve. My app consists of a Home Screen in which users can configure a game, and a game screen that they are taken to when they started their game. Both of these are…
Joris416
  • 4,410
  • 4
  • 26
  • 47