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
13
votes
4 answers

iOS 14 Invalid frame dimension (negative or non-finite)

My App uses GeometryReader with some padding to setup a View frame dimension inside a NavigationView. Since iOS 14 i get the following error message: Invalid frame dimension (negative or non-finite) Here is some example code to test: import…
Franco
  • 141
  • 1
  • 3
13
votes
4 answers

SwiftUI GeometryReader does not layout custom subviews in center

I have a custom view: struct ImageContent: View { var body: some View { Image("smile") .resizable() .scaledToFit() } } Which is being placed into another view with a GeometryReader: var body: some View { …
Tom Shen
  • 1,328
  • 2
  • 11
  • 35
5
votes
1 answer

ForEach and GeometryReader: variable height for children?

I have following example: import SwiftUI struct TestSO: View { @State var cards = [ Card(title: "short title text", subtitle: "short title example"), Card(title: "medium title text text text text text", subtitle: "medium title…
notan
  • 111
  • 9
5
votes
0 answers

GeometryReader is collapsing my List in SwiftUI

I wanted to use the GeometryReader to use some computation. Without my design looks like it should: var body: some View { ZStack { Color(#colorLiteral(red: 0.117543973, green: 0.2897527516, blue: 0.4028342962, alpha:…
gurehbgui
  • 12,496
  • 28
  • 95
  • 160
4
votes
2 answers

why geometry reader doesn't center its child?

red border is geometry Area and black border is text area currently using Xcode12 Beta 3 struct Testing_Geometry_: View { var body: some View { GeometryReader { geo in Text("Hello, World!") …
amin torabi
  • 111
  • 1
  • 6
3
votes
1 answer

SwiftUI: Build View from bottom alignment in scrollView

Is there a way to build UI elements in SwiftUI inside scroll view with bottom Alignment? My use case: I have a screen where the screen has Spacer (What ever is left after allocating below elements) LogoView Spacer() - 30 Some Text - 4/5…
Pablo Dev
  • 117
  • 1
  • 12
3
votes
2 answers

GeometryReader to calculate total height of views

I have a main view with a fixed width and height because this view will be converted into a PDF. Next, I have an array of subviews that will be vertically stacked in the main view. There may be more subviews available than can fit in the main view…
squarehippo10
  • 1,481
  • 1
  • 10
  • 33
3
votes
1 answer

How do I correctly pass a "cell item" to a .sheet from a SwiftUI LazyVGrid?

Here is my example, and I can't tell if this is a bug or not. All my cells load correctly, but when I try to bring up the DetailView() as a sheet, the item pased in is always whatevr item is shown first in the grid (in the top left in my case here),…
Rillieux
  • 267
  • 3
  • 15
3
votes
1 answer

SwiftUI different children alignment and GeometryReader

I want to transform a web app into an iOS app and I am struggling with alignments and the GeometryReader(). This a a screenshot from my original web app template: This is my current version in SwiftUI: With the related code: struct PileRow: View…
T. Karter
  • 428
  • 2
  • 16
2
votes
0 answers

How to use .firstTextBaseline alignment with a view that contains GeometryReader

I have two views in a HStack - the left one is a simple Text view. For the right view, i'm experimenting with using GeometryReader. I cannot get the baselines of the text aligned when I use geometry reader, but I can when I don't use it. Here is…
tng
  • 3,896
  • 5
  • 18
  • 28
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,153
  • 2
  • 14
  • 24
2
votes
1 answer

SwiftUI: height and spacing of Views in GeometryReader within a ScrollView

ScrollView { VStack() { ForEach(0 ..< 5) { item in Text("Hello There") .font(.largeTitle) } } } The above code results in this: When we add a GeometryReader, the views lose their sizing and…
RanLearns
  • 3,731
  • 3
  • 39
  • 69
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
  • 211
  • 1
  • 5
2
votes
2 answers

SwiftUI ScrollView won't center content with GeometryReader

I have a horizontal ScrollView in SwiftUI that I would like to 'dynamically' center. the content within the scrollview will be a dynamic chart, and the user can change the width of it by changing years (5, 10, 15 year chart grows…
steverngallo
  • 101
  • 7
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,156
  • 1
  • 8
  • 21
1
2 3 4 5 6 7 8