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
1 answer

SwiftUI: How to get the length (in points) of a Text inside a GeometryReader

I'm trying to do a simple Bar Chart like this one. Every bar should have a label with the value of bar. If it's a big bar the label should be at the top but on the inside, if it's small it should be just outside. The font of the label should adapt…
Gin Tonyx
  • 383
  • 1
  • 11
0
votes
0 answers

SwiftUI - GeometryReader overrides custom transition

I want to apply a custom transition on a set of views enclosed by a GeometryReader, as shown below: (✔) Custom transition works: var body: some View { ZStack { VStack { VStack { ForEach(modelView.views) {…
Şafak Gezer
  • 3,928
  • 3
  • 47
  • 49
0
votes
2 answers

GeometryReader transitions between views cause onAppear trigger initially

I've been working on a project in SwiftUI 1.0 because it requires support for iOS 13.0 devices (So no fullScreenCover available). I require my application to have clean transition animations between my views, so I'm using GeometryReader extensively…
Frankenstein
  • 15,732
  • 4
  • 22
  • 47
0
votes
1 answer

GeometryReader and ZStack to product screenshot

My goal: To use geometry reader and a screenshot function (already written) to grab just the small portion of an image that falls behind a close button. Setup: I have a ZStack with an Image and a smaller button overtop of it (it is a system image…
Caleb Rudnicki
  • 345
  • 8
  • 17
0
votes
1 answer

SwiftUI ScrollView content height

I have a problem trying to determine the height of a view inside a ScrollView struct ContentView: View { var body: some View { ScrollView{ GeometryReader { geometry in VStack{ …
Stefano Vet
  • 567
  • 1
  • 7
  • 18
0
votes
1 answer

Rotate a view in SwiftUI iOS 14

I want to rotate my view so that it changes its frame and covers the entire screen on rotation. I've tried all the types of rotations along with different anchors. This was working perfectly fine in iOS 13 but inside iOS 14 there is a strange gap…
Rish
  • 1
  • 1
  • 1
0
votes
1 answer

SwiftUI: compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

So I have a GeometryReader encapsulating most of my contentView, struct ContentView: View { var body: some View { GeometryReader { proxy in .... } } } but I'm running into an issue with it. I pass it into…
nickcoding
  • 305
  • 8
  • 35
0
votes
0 answers

SwiftUI - ScrollView & GeometryReader Pagination Bug - @State variable does not change value

so I've implemented pagination to some extent, however, there is a bug. I can only seem to execute self.searchViewModel.loadMoreData() once, and that's only when the view has been presented. This is my full-code: @State var time =…
SwiftUser
  • 555
  • 6
  • 17
0
votes
0 answers

Setting the width of a textfield based on a container proxy in SwiftUI

So I have a geometry proxy that wraps a custom UITextField that I made. The only problem with the text field, is if I type in a long string, the width of the textfield gets larger to accommodate the content size. I figured the best way (I could be…
nickcoding
  • 305
  • 8
  • 35
0
votes
1 answer

Accessing GeometryReader in values set in makeUIView in SwiftUI

so I have rendered a Mapbox Map using the UIViewRepresentable protocol and the following function: func makeUIView(context: Context) -> MGLMapView { let map = MGLMapView() DispatchQueue.main.async { map.styleURL = self.mapStyle …
nickcoding
  • 305
  • 8
  • 35
0
votes
2 answers

SwiftUI - GeometryReader crashes SIGABRT

I'm trying to implement two different views depending on the device width. So the iPad Version of this view should be different to the iPhone version. To do this, I use the GeometryReader to check for the width. However, the app always crashes with…
mtts.91
  • 13
  • 3
0
votes
1 answer

GeometryReader behavior in SwiftUI

I know that GeometryReader takes all spaces available but Why they anchored theirs contents(child views) to topLeading corner? This is my code struct ContentView: View { var body: some View { VStack { GeometryReader { proxy…
PrepareFor
  • 2,448
  • 6
  • 22
  • 36
0
votes
0 answers

Determine length of each line in multiline Text

I write a solution to replace text with some kind of placeholder for updating data. For example from such: I have to get such: But currently with solution: public struct ShimmerText: View { private var text: String @Binding private var loading:…
Konstantin.Efimenko
  • 1,242
  • 1
  • 14
  • 38
0
votes
1 answer

How to break up multiple ForEach statements within GeometryReader and avoid "The compiler is unable to type-check..in reasonable time"

I've been trying to emulate the Ray Wenderlich Swift UI graph tutorial for my own problem and it mostly works well, but I'm repeatedly hitting the 'The compiler is unable to type-check this expression in reasonable time' error due to the complexity…
Scott
  • 1,034
  • 1
  • 9
  • 19
0
votes
0 answers

Why does the HStack make the layout render wrongly?

I'm trying to compose a view using a VStack that nests a HStack and a grid (https://github.com/spacenation/swiftui-grid). The expected outcome is that the HStack and all grid items should render. The actual outcome is that only one item of the grid…
Jobie J
  • 117
  • 5
1 2 3
12
13