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

GeometryReader issue with reading the offset of my images

I am working on a dynamic indicator for a tabView to show a slideshow of images (say 5 images). I am using GeometryReader to determine the minX position of the first picture. This works fine until I scroll to the third picture, where the minX is no…
Daniel C
  • 113
  • 1
  • 8
0
votes
1 answer

iOS SwiftUI - GeometryReader on size / height change

I have this so far: .background( GeometryReader { geo in Color.clear .onAppear { profileViewHeight = geo.size.height …
user19559647
  • 191
  • 1
  • 1
  • 7
0
votes
1 answer

SwiftUI Geometry Reader and Scrollview(.horizontal)

I am trying to create a page that would be similar to the App Store. Where you are displaying the top apps. There would be three rows, and then there would be enough columns to house the data. This would be in a horizontal scroll view. What I am…
0
votes
0 answers

SwiftUI Get TabView Height

Is it possible to detect the height of SwiftUI's TabView? ...Assuming different devices from iOS 15 onwards aren't all 49... I have tried using Geometry Reader and SafeAeaInsets based on other answers but to no avail
Dan
  • 543
  • 2
  • 13
0
votes
1 answer

Updating a Class property with a GeometryProxy in SwiftUI before calling the PreviewProvider

I'm working in SwiftUI and have a GeometryProxy as a property of class used on a view & subview. My code is working fine, but I'd like the subview to render in Preview properly, but to do this, the PreviewProvider needs to have valid GeometryProxy…
Gallaugher
  • 1,593
  • 16
  • 27
0
votes
0 answers

Determine when animating UIView is intersecting/overlapping another view in Swift for iOS

I have a ViewController with five UILabels in my Swift project for iOS, as follows: I'm animating the first UILabel (Label 1) so it slides all the way to the right of the screen, and I want to be able to determine when it intersects with each of…
user4496950
  • 93
  • 1
  • 1
  • 11
0
votes
1 answer

Wrong geometry drag coordinates

I'm trying to drag the gray square inside the white square manteinig the starting point CGPoint(x: 0, y: 0) and respecting the extreme coordinates, see of the image. The code works but I have two problems: the mouse doesn't match the center of the…
Joannes
  • 2,569
  • 3
  • 17
  • 39
0
votes
2 answers

SwiftUI: Different alignment behavior of containers in GeometryReader

A Text element inside a ZStack(alignment: .bottom) is displayed at the bottom of the container (as expected). Tho, if the same ZStack is inside a GeometryReader, the alignment does not behave the same anymore. This code: var body: some View { …
Dominik Seemayr
  • 830
  • 2
  • 12
  • 30
0
votes
1 answer

SwiftUI: view states updated in Xcode preview but not in the built app

Edited: Sorry for the original long story, following is a short minimal reproducible standalone example I can think of: import SwiftUI extension View { /// get view's size and do something with it. func getSize(action: @escaping (CGSize) ->…
lochiwei
  • 1,240
  • 9
  • 16
0
votes
3 answers

Understanding Preferences in SwiftUI

iOS 15 Swift 5.5 Trying to understand preferences, but struggling with GeometryReader I crafted this code reading a tutorial, but it doesn't work correctly. The green box should appear over the red dot, the first one. But it is over the centre one.…
user3069232
  • 8,587
  • 7
  • 46
  • 87
0
votes
0 answers

Getting meaningful coordinates out of geometry reader in SwiftUI

Swift 5.5 iOS 15 Trying to understand geometryReader in SwiftUI, but missed something critical. This app simply draws 4 dots in different places on the screen, but the geometry reader reports them as all being in the same place? How do I get the…
user3069232
  • 8,587
  • 7
  • 46
  • 87
0
votes
1 answer

Cannot dynamically resize swiftui view to new runtime defined dimensions

I am writing a view with a RectangleView which I would like to shrink of a percentage (let's say 0.8 percent of the current size) every time I tap the RectangleView itself. Here an example of the view: struct MainView: View { @State private…
MPira
  • 3
  • 2
0
votes
0 answers

SwiftUI: List containing children composed of List

I have a view that creates a List, and using a ForEach, iterates over a list of children, and each of those children is rendered inside a view. The problem is that the child view is also composed of a List, so I end up having the following…
noloman
  • 11,411
  • 20
  • 82
  • 129
0
votes
1 answer

Custom Rating view with nested H and VStacks leads to weird frame

I'm trying to clone this view: Unfortunately I have a problem with the Geometry Reader (I guess). It's making a bigger frame then the actual rectangle (see blue area): Same applies to the stars as well: Can you point me to my issue? Is something…
SwiftUIRookie
  • 591
  • 7
  • 16
0
votes
1 answer

Align Rectangle to bottom in ScrollView / GeometryReader view not working

I am trying to get a rectangle to be aligned in a GeometryReader view, that is nested inside a HStack and then ScrollView. I can not get the Rect() to be aligned to the bottom of the view, it is only drawn from the top. This does not work, the Rect…
JohnKubik
  • 69
  • 1
  • 1
  • 12