Questions tagged [swiftui-zstack]

26 questions
14
votes
3 answers

SwiftUI ZStack: Align some descendants to bottom, and some to top

As a root view of my app, I have a ZStack, and I would like to add two floating bars, one to the bottom, and one to the top of the viewport. With a single bar it's easy (ZStack(alignment: .top)), but is there a way to add multiple descendants, and…
Tomáš Kafka
  • 4,405
  • 6
  • 39
  • 52
9
votes
2 answers

Positioning inside ZStack

I want this red rectangle to be repositioned to the left bottom corner but for some reason my alignments and paddings do not work as I expected. What am i doing wrong and how to move it to the left bottom corner? Code: struct ContentView: View { …
eugene_prg
  • 948
  • 2
  • 12
  • 25
3
votes
2 answers

How to align text within a SwiftUI ZStack for smaller screen sizes?

I'm attempting to align a Text view within a ZStack. It works fine for larger screens like the iphone 11 plus max but on smaller screens the text will go off screen if I use trailing or leading alignment like below. I get the same result on the…
Declan McKenna
  • 4,321
  • 6
  • 54
  • 72
2
votes
1 answer

How to construct a SwiftUI view using async

I've got a little swiftUI program that displays photos from a given day as stacks of photos for each year. Simplified code below. I read the photos into resultPhotos as a dictionary with each key the year, and each value a PHFetchResult. I then…
Martin
  • 1,570
  • 3
  • 19
  • 32
2
votes
2 answers

In SwiftUI what is an easy way to align more than one view in ZStack

I have a view and I want to add two icons to it, at top right side and at bottom right side. I managed to do that: I used two ZStacks: ZStack(alignment: .bottomTrailing) { ZStack(alignment: .topTrailing) { …
user121882
  • 151
  • 4
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
1
vote
1 answer

ZStack z-index offset on visionOS with Model3D views

If I take a ZStack and add a bunch of Model3D views to it (to arrange them in 2D space), the ZStack will give each successive view an adjustment to the z-axis, such that they appear to be placed on different planes. Is there a way to disable this?
Ben Gottlieb
  • 85,404
  • 22
  • 176
  • 172
1
vote
1 answer

isssue with ZStack and list

I have a RocketView View to view SpaceX rockets with the SpaceX API. I have an issue with ZStack or VStack in the RocketCell View where the cell is not showing the whole image in the list. How can I make it so that the entire image is displayed? …
NinjaDeveloper
  • 1,620
  • 3
  • 19
  • 51
1
vote
0 answers

ZStack explicit animation not working when conditionally hiding/showing a view

I want to create some sort of banner view that either moves in or out with animations when some state changes in SwiftUI. It feels like a basic task to do but the transition when showing the banner is not being animated. Hiding works fine. So for…
ph1psG
  • 568
  • 5
  • 24
1
vote
1 answer

Is there a way to keep rounded corners when scrolling through content vertically in scrollview

Before scrolling starts, everything looks great with rounded corners displaying on the screen. The problem comes when user starts scrolling through the page, the top corners gets replaced by the content's background color (sharp corners)... Is there…
Ryan Fung
  • 2,069
  • 9
  • 38
  • 60
1
vote
2 answers

SwiftUI: Animate Transitions

How can I animate slide transitions between different views? In following sample code I made a Picker that chooses which view to show and my goal is to have a transition that looks similar to the NavigationLink transition. At the moment it doesn't…
Isaak
  • 1,107
  • 2
  • 11
  • 29
1
vote
0 answers

SwiftUI Zstack subview not offsetting properly

I have a login page where the views are embedded in a ZStack the behavior that I am aiming for is when I click on either the email and password fields the ZStack should offset -300 vertically so that it wouldn't be covered by the keyboard. I…
devios
  • 225
  • 2
  • 13
1
vote
1 answer

SwiftUI place around center object

Say the blue rectangle is in the center of the red rectangle, and the green needed to be on top and the yellow on the left. How would one do this in SwiftUI with alignment guides? None of the sizes are known, but the yellow and blue height match,…
magnuskahr
  • 1,137
  • 9
  • 17
1
vote
2 answers

Prevent last rows in List to be covered by other view in ZStack

I have a List partially covered by a translucent view (let's call it the overlay). My problem is that for long lists last rows are not accessible since they are covered by the overlay. I'm using a ZStack to layout the final view. I've thought about…
cbuchart
  • 10,847
  • 9
  • 53
  • 93
0
votes
0 answers

swiftui zstack are not fully centered

My code is as bellow: struct Clock10View: View { let light: Bool var body: some View { ZStack() { Rectangle() .frame(width: 6, height: 6) .foregroundColor(.gray) Rectangle() …
mars
  • 109
  • 5
  • 21
1
2