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

Drawing 2 dots and a line between them in SwiftUI

Swift 5.5 iOS 15 Drawing 2 dots at random places, noting their origins and then trying to use the information to draw a line between them. Almost there, and yet the result is wrong? What am I doing wrong? struct ContentView: View { @State var…
user3069232
  • 8,587
  • 7
  • 46
  • 87
1
vote
1 answer

My love/hate relationship with GeometryReader

I'm new to SwiftUI - not new to iOS development. I have a lot of custom design/drawing to do and that seems particularly difficult in SwiftUI. Please bear with me and prepare for a long one. What's great about SwiftUI is that it's based on…
esbenr
  • 1,356
  • 1
  • 11
  • 34
1
vote
0 answers

iOS, Swift, CoreGraphics, alternative for UIGraphicsGetImageFromCurrentImageContext

I am currently working on the photobooth app. My friend and I have a dispute over which tech stack we should use to generate the ready-to-print image that is generated out of the frame and some pictures taken by the camera, added into the blank…
Jakub Gawecki
  • 801
  • 2
  • 6
  • 14
1
vote
1 answer

SwiftUI - How can I use ObservedObject or EnvironmentObject to store GeometryReader data?

I am trying to follow the design created for an app which has some objects placed in the middle of the screen. The objects should have a size and padding proportional to the device's screen size, meaning they should appear bigger if the screen is…
Tomas
  • 153
  • 1
  • 1
  • 12
1
vote
1 answer

LinearGradient with mask does not fill the whole area

I'm creating a line chart view, inspired by this blog post. The lines are drawn with Path and the gradient with a LinearGradient and a mask, and they are in overlays on top of each other. My main issue is that, as you can see in the screenshot, the…
1
vote
1 answer

How can I prevent my SwiftUI view resizing on scroll

I’m hoping someone can point me in the right direction - I have been experimenting with SwiftUI, I’ve created a view somewhat similar to the Twitter Profile UI. I seem to have a weird effect when the header collapses. There is a ‘sweet spot’ in…
Harry Blue
  • 4,202
  • 10
  • 39
  • 78
1
vote
1 answer

SwiftUI: Showing HTML text inside a ScrollView

I'm trying to show some HTML text in an app I'm making, but I can't get it to work properly. The problem is that the view that contains the text is always shown with the height of only one line, even tho it is wrapped in a ScrollView. In the…
noloman
  • 11,411
  • 20
  • 82
  • 129
1
vote
1 answer

SwiftUI - How to get GeometryReader size/height from different View?

How can I access the size of a View from another View? To get the height of the "Hello world!" text, I attached a .background() of GeometryReader to it. For now, I'm just printing the height using let _ = print(proxy.size.height). struct…
aheze
  • 24,434
  • 8
  • 68
  • 125
1
vote
1 answer

SwiftUI Using Geometry Reader with ForEach

I can't figure out why my ForEach loop is making my views not scale correctly inside their parent view. If I comment out the ForEach loop and uncomment //.frame(width: geometry.size.width, height: 10) the RoundedRectangle is scaled correctly in its…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
1
vote
1 answer

Using GeometryReader without modifying the view

I am trying to use GeometryReader here to build views based on the size available, however because this view is embedded in a parent view with padding, it is not drawing correctly. I know from other SO answers, some have said to use the…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
1
vote
1 answer

How can I remove the animation from geometryReader?

I just want to remove the animation on the offset. Is something like this possible ? If you do not remove that animation, when I scroll as in the image below, the visual animation will go into effect and a hitch occurs. remove the animation on the…
Ufuk Köşker
  • 1,288
  • 8
  • 29
1
vote
0 answers

Image flickering while geometryReader swipes

The picture flickers when swiping when I use NavigationLink. (Section One) I solved the image flickers problem. I used a different NavigationLink function. (Section Two) the problems don't stop there. When the navigation is running, the image shifts…
1
vote
0 answers

SwiftUI: Get height of content inside of ScrollView to update frame

I need to update the height of my ScrollView depending on the content height inside of it. I have a working carousel below: struct PostsPaging: View where Content: View { @Binding var index: Int let maxIndex: Int let content: () ->…
Ryan
  • 155
  • 1
  • 14
1
vote
2 answers

SwiftUI measuring the height of a view

I tried measuring the height of a view by using coordinatespace on it but the value it returns is the height of the full screen. Any idea why my code isn't giving me what I want ? struct GeoReader: View { var body: some View { …
Bjorn Morrhaye
  • 687
  • 9
  • 30
1
vote
1 answer

SwiftUI: How to calculate a view's size based on it's frame's size without using a Geometry Reader?

The below code works great, however the geometry reading is causing me issues upstream, so I would like to have the same logic to build the view's width based on available space but without using Geometry Reader. Is it possible? var body: some…
GarySabo
  • 5,806
  • 5
  • 49
  • 124