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

How can I detect the View overflowing the screen?

Question: How can I detect the View overflowing the screen? For example, I want to write +1(+n) for the view that goes out of the screen. TagList: struct TagListView: View { var tags = ["iPhone X", "iPhone 11", "iPhone 12", "iPhone 12 Pro…
Ufuk Köşker
  • 1,288
  • 8
  • 29
0
votes
1 answer

SwiftUI size to fit Font using GeometryReader, font is too big

I am using GeometryReader to calculate the size of font to use to fit several lines of text, however it is always too big. What can be wrong with my calculation? Here's a simply Playground import SwiftUI import PlaygroundSupport struct MainView :…
Darren
  • 10,182
  • 20
  • 95
  • 162
0
votes
1 answer

Get coordinates in real time of a moving view in SwiftUI

I am moving a view called Point (which is basically a point), the point is moving in the screen every 2 seconds, and I need to update the coordinates in real time to know exactly in which position is on the transition. Basically, I tell the point to…
kike
  • 658
  • 1
  • 8
  • 26
0
votes
1 answer

Swift ui widget list of items that take up too much space

As you can see from the image I have a widget with a series of elements, I have to put at the end of the series of elements then the word Next update which must find some at the end of the widget. The problem is: if there are few elements, Next…
Paul
  • 3,644
  • 9
  • 47
  • 113
0
votes
1 answer

SwiftUI fill a View inside a switch

Does anyone know a correct way to do the following: I have a view which produces a path and I want to fill it either with a color or with a gradient (which are different types). For this, I have a enum which I pass to the view from the parent…
annaoomph
  • 552
  • 1
  • 4
  • 22
0
votes
1 answer

SwiftUI | GeometryReader: Smooth resizable Header when scrolling through List

I am new to SwiftUI and I want to recreate the Contact-Card View from the Contacts App. I am struggling to resize the Image on the top smoothly when scrolling in the List below. I have tried using GeometryReader, but ran into issues there. When…
0
votes
1 answer

SwiftUI - Change layout of card based on height of Text view

Based on the height of a Text-view, the Card is supposed to either show the complete text (if the input text is short) or display parts of the text and a "Continue reading"-button, which navigates to a Detail-view. Unfortunately, the GeometryReader…
Peanutsmasher
  • 220
  • 3
  • 13
0
votes
0 answers

SwiftUI incorrect frame size

My view is getting offset or zoomed in and I cant seem to figure it out. Here is what I get: Here is what I want: I tried to track down the error location and I think this is possibly where my frame gets messed up. let frame = reader.frame(in:…
0
votes
0 answers

GeometryReader's child view overflowing width

I'm currently using GeometryReader and Image to have images in a 3-column grid. In this grid, I want when user taps the image, they will see the bigger version of it. However, when I implemented this, GeometryReader is not functioning properly. The…
S. Hwang
  • 71
  • 1
  • 12
0
votes
1 answer

Make a VStack height according to content in SwiftUI

I want to make a "card" but the height depends a list of items, I don't how to set a different value according to my sizes list... Example: ContentView Struct struct ContentView: View { @State private var orderList : [Order] = [ …
Antonio Labra
  • 1,694
  • 2
  • 12
  • 21
0
votes
1 answer

Swift: Finding and plotting the hours in between two Dates

I am trying to create a UI like the below. I have a startDate and endDate (e.g. 1:55am and 11:35am). How can I proportionally (using Geometry reader) find each hour in between two dates and plot them as is done here? I am thinking at some point I…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
0
votes
1 answer

Dynamic TextEditor overlapping with other views

So I have made a successful dynamic TextEditor but when I try to combine views, it overlaps the other elements and no longer expands as you type. I am pretty sure this has to do with Geometry Reader but I am not sure how to do it without that.…
0
votes
0 answers

SwiftUI - Detect when global position of a View is changing

I am actually a beginner in SwiftUI. I want to know if there is a way to detect when the global position of a View is changing. For the moment I can get the global position of the view with GeometryReader, but I definitely can't detect when it is…
Rivoks
  • 1
0
votes
1 answer

A view extension that runs conditional code based on its GeometryReader results

I’ve created a View extension to read its offset (inspired by https://fivestars.blog/swiftui/swiftui-share-layout-information.html): func readOffset(in coordinateSpace: String? = nil, onChange: @escaping (CGFloat) -> Void) -> some View { …
Barrrdi
  • 902
  • 13
  • 33
0
votes
0 answers

GeometryReader inside ScrollView - scroll doesn't work anymore

I'm trying to get scroll offset by placing GeometryReader inside of ScrollView but it disabled scroll (LazyVStack's area bounces back on scroll attempt). It seems like GeometryReader takes exactly the same size as LazyVStack and LazyVStack has…
eugene_prg
  • 948
  • 2
  • 12
  • 25