61 questions
2
votes
2
answers
109
views
How can I prevent a view covered by another one in a ZStack from setting the cursor style?
I would like the view show on top to prevent the covered view from receiving any mouse event. According to How to prevent the ZStack lower level View from reacting?, I can disable the covered view. ...
0
votes
0
answers
58
views
Bottom Sheet gets pushed down by other elements in the same ZStack
I’m building a custom bottom sheet in SwiftUI using ZStack. Everything works fine when I just preview the bottom sheet alone, or when the ZStack is not occupied by any other elements. However, as soon ...
-1
votes
1
answer
101
views
Creating a Stack that have the combined behavior of VStack and ZStack
I want to create a custom class for a stack that will show some kind of stacked cards effect like so:
It will be used on top of the Main / Root container. The stack will be aligned at the bottom of ...
1
vote
1
answer
117
views
Negative padding lifts button in SwiftUI but not tappable area so button is not recognizing tap
I have a close or dismiss view button on an iOS app that I am trying to place in the upper left hand of a SwiftUI View. The button has an image within it and it action is to dismiss the view.
To the ...
1
vote
2
answers
117
views
In SwiftUI, what's the best way to anchor one view to the containers center, while anchoring an additional view to its edge? [closed]
I'm newish to SwiftUI and trying to understand how I can keep one view horizontally centered on the device screen, while anchoring an additional view to its trailing edge (without uncentering the ...
0
votes
0
answers
47
views
How to make a rectangle rotate around its own center in a ZStack
I'm working with SwiftUI and I have a rectangle inside a ZStack that I want to rotate. However, the rotation is happening around the center of the entire ZStack, not the center of the rectangle itself....
0
votes
1
answer
291
views
HStack Move Only One Item in Scroll SwiftUI
I am trying to create a horizontal scroll view in SwiftUI where I can move only one item at a time, and I want to maintain the proportions of the peeking view (i.e., the portion of the item that ...
0
votes
0
answers
76
views
How to change apps color via ContentView() and @MainView using ZStack inside TabView()?
this is my ContentView()
struct ContentView: View {
@State private var selectedTab: Tab = .view1
var body: some View {
NavigationView{
ZStack{
Color(.green)
...
1
vote
1
answer
108
views
Why does LinearGradient() fail to work in a ZStack > NavigationStack?
I am new to SwiftUI and hoping to understand why LinearGradient() is not working when applied to a ZStack, followed by a NavigationStack.
Any guidance would be appreciated!
var body: some View {
...
0
votes
1
answer
62
views
SwiftUI: Dynamic Label and Image adjust
We have vertically aligned multiple labels and top tight Image is align to first label.
If first label has not enough content then second label will be move up and vice versa.
image height will be ...
0
votes
1
answer
571
views
Conditionally show text on top of an image
I want to display a list of images. Each image have an associated text, and I want to display that text like a "popover" in style (but how it is achieved is not important - it doesn't have ...
0
votes
1
answer
2k
views
Content in a full-screen ZStack not centering as expected
Consider the following (in a landscape-only app):
struct ContentView: View {
var body: some View {
ZStack {
Rectangle()
.foregroundColor(.blue)
.frame(width: UIScreen....
2
votes
2
answers
2k
views
How to position a button in lower right of screen in SwiftUI
Consider the following view:
var body: some View {
GeometryReader { geo in
ZStack {
HStack(spacing: 0) {
VStack {
Text("...
0
votes
1
answer
426
views
Applying ClipShape in SwiftUI Modifies Frame Of Clipped View
Lets say in SwiftUI we have a problem where we want a View that consists of:
An overall frame of reference in the form of an aspect ratio (the View will always have this aspect ratio)
A basic (or ...
3
votes
3
answers
602
views
Moving an image over a sheet SwiftUI
In a screen design, I am showing a sheet from the bottom, and in this section I want to move an image above the sheet part. In this part, when I move it up with offset, it only remains in the sheet, ...
4
votes
2
answers
1k
views
Why does AsyncImage with .fill ContentMode cover buttons in a ZStack in iOS 17?
I am working on a SwiftUI view that displays an image fetched from a URL using AsyncImage. I want the image to fill the entire screen, and I have a row of buttons overlaid at the bottom of the image ...
0
votes
1
answer
99
views
ScrollView affecting the Views inside Geometry Reader
Main Content View:
struct ContentView: View {
@State var editing: Bool = false
@State var inputText: String = ""
@State var vOffset: CGFloat = 0
@State var hOffset: ...
1
vote
2
answers
111
views
Understanding Reference Frame of View Composed of Rotated Objects in SwiftUI
I'm following this SwiftUI tutorial and encountered an issue with the positioning of badgeSymbols in Badge.swift. Here's the relevant code:
Badge.swift: (where the repositioning is applied)
import ...
0
votes
2
answers
197
views
SwiftUI ScrollView can't scroll down to all the content of ZStack
SwiftUI ScrollView can't scroll all down to all the content of the included ZStack.
struct TestView: View {
var colors: [Color] = [.red, .orange, .yellow, .green, .mint, .teal, .cyan, .blue, ....
1
vote
2
answers
1k
views
Layout a view's vertical position inside Zstack in SwiftUI
I'm facing some challenges to layout this prototype in SwiftUI.
I used ZStack to layout the views. But my main problem is to position the profile image view's first half on the top the red background ...
0
votes
0
answers
50
views
Take over TabView's view but keep the tabs visible
When someone clicks on Notification, I want to show a view. However, I still want tabs visible at the bottom of the screen so they can go back to whatever tab they want.
I tried adding invisible ...
0
votes
1
answer
829
views
How to start the overlay after last Text from the view in SwiftUI?
I have a ScrollView with some text in it and I want to use .overlay for an Image to start after last Text or element from the view.
In a simple way I used Color to showcase what I have and what I want ...
1
vote
1
answer
115
views
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)
....
-1
votes
1
answer
210
views
How can I measure an item inside of a VStack in SwiftUI?
I am building an app for iOS in Xcode. New with this, as you can see.
I created a VStack, with 3 rectangles in it, all of them taking al the width of the screen (the app is only portrait):
First one ...
2
votes
1
answer
194
views
How can I combine two half view with zstack in SwiftUI?
I have a map pin view that represents an action.
This is the code
VStack {
ActionView(action: place.actions.first!)
.frame(width: 35,...
1
vote
1
answer
935
views
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 ...
1
vote
0
answers
801
views
Opacity of the button affects its "clickability"
I've run into a very strange issue. I have a SwiftUI app (iOS) where I have a full-screen ZStack: inside, as a "bottom layer", I have a full-screen Map, and on top I have a button (it is ...
0
votes
1
answer
956
views
Show fullscreen popup in SwiftUI
I'm having problems showing fullscreen popups in SwiftUI. My app structure is a MainView with a TabView with 2 tabs.
This is a sample of my app structure:
struct UIMainView: View {
var body: ...
0
votes
3
answers
188
views
Is there a way to move HStack to leading?
I am having a problem with HStack which has bigger width than the parent view showing centre not leading.
struct WidgetEntryView : View {
var entry: Provider.Entry
var body: some View {
...
1
vote
1
answer
1k
views
SwiftUI ZStack and Xcode 3D View Hierarchy
I'm learning SwiftUI. When I have a ZStack say
ZStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
}
...
0
votes
2
answers
153
views
VStack flashing of space between views
The VStack has two components header and detail. When we tap on the "show" button, it shows the View (header + detail of the VStack). However, it results in Flashing effect when the view ...
1
vote
1
answer
75
views
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 ...
0
votes
2
answers
803
views
I want to draw this two rectangles in SwiftUI
I'm struggling on creating two vertical bars with lines and dash box. I would like to receive some suggestion on how to do this.
This is what I'm aiming to do:
Currently this is my code.
import ...
0
votes
1
answer
114
views
Zstack alignment issue with overlapping circles a on NavigationView
I have two circles on a Zstack, but they are not aligned if the view is rendered on NavigationView.
struct SpinnerView: View {
@State private var isLoading = false
var body: some View {
...
6
votes
1
answer
8k
views
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 ...
0
votes
1
answer
57
views
Why ZStack not getting rotated and scaled , But the inside contents getting
I am applying rotation gesture and magnify gesture in a ZStack. But the ZStack is not getting rotated , but the image inside the ZStack is getting rotated and scaled upon the gesture while I did ...
0
votes
1
answer
468
views
SwiftUI Align VStack Top Leading in ZStack
I have a Stack I am using to create a graph with 2 different lines, but I also want to have 2 labels on the graph. I want these labels to be in the top left of the ZStack but cannot figure out how. ...
1
vote
1
answer
834
views
How to bring an Image to foreground in LazyVStack/ScrollView SwiftUI?
I have a LazyVStack of Post Views with images in those views (similar to Instagram). When I'm zooming in on one of the images, I would like for that image to overlap over all other content. However, ...
0
votes
1
answer
248
views
SwiftUI ZStack not showing bottom element with List
When put Image to the bottom of ZStack , image just not showing
struct ContentView: View {
var body: some View {
VStack{
ZStack{
Image(systemName:"...
0
votes
3
answers
11k
views
SwiftUI-How to make background colour fill up the entire screen
I'm trying to make an app and I want to have a background colour for the app so I put the colour in the assets folder but the colour only fills up 3 quarters of the screen, leaving the top half empty.
...
0
votes
1
answer
176
views
Why does adding a HStack inside a VStack wreck size calculations for a ZStack bubble around text elements?
I want to produce a bubble-like view with various pieces of text on a rounded rectangle background, sized to fit the text. I have arrived at this:
var body: some View {
HStack {
...
1
vote
0
answers
268
views
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 ...
-1
votes
2
answers
730
views
SwiftUI ZStack first element is not displayed
I'm new to SwiftUI, and I have a simple app with a ZStack:
struct ContentView: View {
@State var num : Int = 1
var body: some View {
NavigationView{
ZStack{
...
1
vote
2
answers
2k
views
SwiftUI - How to overlay or ZStack a View so that it doesn't affect the position of the underlying View?
I want to place an image either on top of, or between lines, depending on the position variable:
struct ContentView: View {
@State var position = 5
var body: some View {
VStack(spacing: ...
2
votes
2
answers
2k
views
Unexpected layout issues with SwiftUI Image and ZStack
I'm trying to create a view composed of two parts - the top part is an image with a piece of text overlaid in the top left corner. The top part should take up 2/3 of the height of the view. The bottom ...
-1
votes
1
answer
404
views
How to align ZStack View to elements in a view below it
I have some vstack views, and a zstack view (its a dropdown menu).
I need the top of the zstack view to align itself perfectly with the text of VStack 2 Text like this
I think I need to utilize ...
0
votes
2
answers
572
views
SwiftUI: Different alignment behavior of containers in GeometryReader
A Text element inside a ZStack(alignment: .bottom) is displayed at the bottom of the container (as expected). Tho, if the same ZStack is inside a GeometryReader, the alignment does not behave the same ...
3
votes
1
answer
900
views
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 ...
0
votes
1
answer
1k
views
SwiftUI List - some part of row content is overlapped by next row
When I am trying to add a plus button, which is overlapped on two rows of the list. The code works fine for cases: 1) When view will appear, 2) Scrolling from top to bottom (Every time). However, the ...
6
votes
2
answers
4k
views
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: ....