Questions tagged [zstack]

68 questions
40
votes
5 answers

SwiftUI HStack with wrap and dynamic height

I have this view to show text tags on multiple lines which I got from SwiftUI HStack with Wrap, but when I add it in a VStack the tags overlap any other view that I put below. The tags are shown properly but the height of the view itself is not…
Ludyem
  • 1,709
  • 1
  • 18
  • 33
36
votes
1 answer

Difference between a ZStack or using .overlay()

What is the difference between using a ZStack versus using the .overlay() modifier. Apple says: ZStack = "A view that overlays its children, aligning them in both axes." .overlay = "Layers a secondary view in front of this view." Some…
Michael Ozeryansky
  • 7,204
  • 4
  • 49
  • 61
15
votes
3 answers

SwiftUI Zstack – Make element ignore safe area and another one don't

I have a Zstack like this: ZStack { Image("beach") .resizable() .edgesIgnoringSafeArea(.all) .scaledToFill() VStack { // with a lot of stuff } } I want the image to ignore the safe area, but the Vstack must respect the safe…
Duck
  • 34,902
  • 47
  • 248
  • 470
14
votes
1 answer

How to set UIHostingController's background color to clear?

I need to be able to see through my SwiftUI Views as well as the UIHosting Controller presenting them in order to see a background image underneath them. The code below still shows a white rectangle under my SwiftUI View. Paul Hudson says to use…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
6
votes
0 answers

Present a view on top of a navigation View in swiftUI

I have a MainView which is a Navigation View and it presents a View through NavigationLink i.e. SubView here. In SubView, I want to present a view on top of the subview on a button toggle while hiding the navigation bar and the subview contents. I…
user2580
  • 239
  • 5
  • 13
5
votes
3 answers

ZStack alignment not centered when in GeometryReader?

I have the following view: struct TestView: View { var body: some View { GeometryReader { geo in ZStack(alignment: Alignment(horizontal: .center, vertical: .center)) { …
zumzum
  • 17,984
  • 26
  • 111
  • 172
3
votes
1 answer

VStack Lower Than Expected SwiftUI

Even though in preview VStack looks promising when I run the app on the simulator or on the phone it appears lower than expected. You can see there is a big gap at the leading of the view from comparing the two images. I have also added layer's…
Mert Köksal
  • 817
  • 1
  • 7
  • 26
3
votes
2 answers

SwiftUI Button on top of a MKMapView does not get triggered

I have a button on top of a MKMapView. But the button does not get triggered when it's tapped on. Do you know what's missing? MapView.swift import SwiftUI import UIKit import MapKit struct MapView: UIViewRepresentable { func…
Dogahe
  • 1,380
  • 2
  • 20
  • 50
3
votes
1 answer

How to clip subviews using ZStack with SwiftUI?

I need to clip the view behind a Text by using its Rectangle. When I add a Text over this 1-pixel height rectangle, I need it to "clip" the subview below, so the text can be readable. Of course, if I use a solid background color, it's easy to do,…
mcatach
  • 1,227
  • 13
  • 23
3
votes
2 answers

How to remove padding in the ZStack SwiftUI

I'm getting weird padding when trying to put another VStack in ZStack. How to remove it? struct ContentView: View { var body: some View { VStack{ VStack{ Text("1") } .frame(width: 200, height: 50) …
Роман
  • 51
  • 1
  • 5
2
votes
1 answer

SwiftUI: Spacers won't scale down because BG Image will not adjust to device size

I use a ZStack to display a fullscreen background image underneath the main UI. The main UI consists of a VStack with multiple views separated by flexible Spacers to scale down or up on different device sizes. Now I experience that the Spacers will…
FrankZp
  • 2,022
  • 3
  • 28
  • 41
2
votes
0 answers

Adding a ZStack around a TabView/NavigationView moves content up into safe area when .blur is used

My application uses a TabView and contained in it there is a NavigationView so I can transition to different views on the selected tabs. I am using .navigationTitle together with .navigationBarTitleDisplayMode(.large) to show users where they are…
Simon
  • 41
  • 5
2
votes
1 answer

How to set content to Top in ScrollView?

I am trying to set the content Text("Test.....") inside the scroll view to the top. Without using .frame (maxHeight: 150) and the like. I just need to kick it up under Text ("123")) but nothing comes out. And while scrolling in all directions should…
2
votes
1 answer

SwiftUI: implementing ZStack inside of navigationBarItems shows navigationBarItems error

I'm trying to implement a ZStack inside of navigationBarItems to load a custom alert. Here is my implementation: var body: some View { VStack{ List(self.itemsStore.names){ item in Text("hello") } …
user2924482
  • 8,380
  • 23
  • 89
  • 173
2
votes
1 answer

Using SwiftUI to annotate an overlay with existing content shown beneath Path view

I have a SwiftUI app where some content is presented to the user, and then the user will annotate over it with a Path view. The issue I have is that when I use a clear background for the drawing view, or no background at all, the content beneath it…
CodeBender
  • 35,668
  • 12
  • 125
  • 132
1
2 3 4 5