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
1
vote
0 answers

Hide Tabbar when clicking on Card with Geometry Reader in SwiftUI

I am using a custom Tabbar and implemented the same animation you can find on the App Store from iOS, when you click on a card in the Today's View. As soon as a card is expanded I would like to hide the Tabbar. Currently I am hiding it with a bool…
1
vote
1 answer

Observe frame changes in SwiftUI

I have view that can be dragged and dropped on top of other views (lets say categories). To detect which category view I'm on top of, I store their frames in a frames array, which happens in onAppear of their invisible overlays. (This is based on…
hoshy
  • 351
  • 2
  • 11
1
vote
1 answer

GeometryReader behaves oddly with an extracted view

In this example, the "hello" text is placed in the middle of the screen, as expected. struct ContentView: View { var body: some View { GeometryReader { geo in Text("hello") .background(Color.green) } …
thedp
  • 8,178
  • 16
  • 49
  • 87
1
vote
2 answers

Why is the body of a GeometryReader evaluated twice? Also first time with dimensions of zero?

I have a GeometryReader nested inside of a NavigationView. Inside the GeometryReader I am using the dimensions supplied by the GeometryProxy with an if-statement. In my project I stumbled over the fact, that the content inside the GeometryReader is…
DFox
  • 86
  • 8
1
vote
1 answer

"Type '()' cannot conform to 'View'; only struct/enum/class types can conform to protocols"

EDIT: Explanation to the problem This code is producing an error where the poster doesn't know how to solve it. This is a new edit of the previous post. I received the error on >Geometry Reader. This post includes all of the code. This new post…
Sydney
  • 23
  • 4
1
vote
1 answer

SwiftUI: How to find the height of an image and use it to set the size of a frame

So I've been trying to figure out how to find the height of an image in SwiftUI for a while now with no success. Essentially I have portrait/landscape images, which the portrait ones I want to display at about 600 pt tall, whereas the landscape…
Jabinator1
  • 115
  • 10
1
vote
1 answer

GeometryReader make Text height wrong

Not for all texts, but for specific length of text GeometryReader decides that Text should contains two lines: public var body: some View { ZStack { if loading { Text(text) .foregroundColor(.clear) …
Konstantin.Efimenko
  • 1,010
  • 1
  • 9
  • 30
1
vote
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
  • 651
  • 10
  • 18
1
vote
1 answer

Animation not working with combination of GeometryReader and NavigationView

I've got an animated Image wich is sliding up and down, using the offset and a timer. This works totally fine until you combine a GeometryReader and a NavigationView. For both, NavView and GeoReader on their own, the animation is working as well.…
1
vote
1 answer

SwiftUI GeometryReader compact size

I would like my LoadingTitle to have a width of 70% of the screen so I use the GeometryReader but it makes the vertical size expand and my LoadingTitle takes much more vertical space. I would like it to remain as compact as possible. When using…
Jan
  • 6,366
  • 7
  • 40
  • 58
1
vote
2 answers

set @State var inside geometryReader

how is possible to set a @State var inside a geometryReader this is my code @State var isTest:Int = 0 var body: some View { VStack{ ForEach(self.test, id: \.id) { Test in VStack{ GeometryReader { geometry in …
Stefano Vet
  • 355
  • 1
  • 4
  • 12
1
vote
1 answer

GeometryReader Takes Extra Space in SwiftUI

The code below is to create a custom button import SwiftUI let skyBlue = Color(red: 75/255, green: 170/255, blue: 193/255) struct RegisterButtonView: View { var body: some View { GeometryReader { geo in HStack { …
Lance Chan
  • 11
  • 1
1
vote
2 answers

SwiftUI: Drawing rectangles around elements recognized with Firebase ML Kit

I am currently trying to achieve to draw boxes of the text that was recognized with Firebase ML Kit on top of the image. Currently, I did not have success yet and I can't see any box at all as they are all shown offscreen. I was looking at this…
1
vote
1 answer

How to use GeometryReader without it filling the View

This is the layout I'm aiming for. import SwiftUI import PlaygroundSupport struct TestView: View { let text: String var body: some View { Text(self.text) } } struct ContentView: View { var body: some View { …
Peter Warbo
  • 10,484
  • 12
  • 87
  • 186
1
vote
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
  • 11,371
  • 11
  • 72
  • 126