Questions tagged [hstack]

A Swift UI view that arranges its children in a vertical line.

This document contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

HStack - SwiftUI | Apple Developer Documentation

153 questions
3
votes
1 answer

SwiftUI: List, NavigationLink, and badges

I'm working on my first SwiftUI app, and in it would like to display a List of categories, with a badge indicating the number of items in that category. The title of the category would be on the left, and the badge would be right-aligned on the…
Shadowman
  • 11,150
  • 19
  • 100
  • 198
3
votes
1 answer

SwiftUI Pan gesture

I'm new to SwiftUI. I'm showing a series of items in an HStack. They don't need to move, but I'd like to highlight them as the user drags their finger over them, and change a separate view somewhere else to give more information about the…
CompC
  • 381
  • 2
  • 19
3
votes
3 answers

SwiftUI how do I perfectly align on of my object in my HStack in the center of my screen?

I am trying to figure out how to align my "Create" Button in the exact middle of my screen with my "share" button to the right of my centered "Create" Button, without using arbitrary numbers. HStack (spacing: 40) { …
bain
  • 335
  • 1
  • 6
  • 17
3
votes
4 answers

Center Item Inside Horizontal Stack

If I have 3 items inside a Horizontal Stack, I thought I could do something like this: HStack{ Text("test") Spacer() item2() Spacer() Text("test") } to center item2() in between the two Text views. However, the…
Evan
  • 1,892
  • 2
  • 19
  • 40
3
votes
1 answer

Using swiftUI how can i add datePicker only while textField is in editing mode?

I have added datePicker for now inside HStack. I want to show datePicker only when textField is in editing mode. struct EditProfile: View { @Binding var profile: Profile var body: some View { List { HStack { …
PinkeshGjr
  • 8,460
  • 5
  • 41
  • 56
2
votes
0 answers

Button not working in HStack in Toolbar Navigation Bar SwiftUI

I am trying to add a second line of buttons in my toolbar navigation view in SwiftUI so that it looks like this: However, these bottom buttons lose their functionality. I put them in a HStack in the Toolbar. This HStack is located in a VStack in a…
kmcclenn
  • 127
  • 11
2
votes
0 answers

SwiftUI grid layout using Stack

What I am trying to achieve Making this grid layout using Stack in SwiftUI How I've currently achieved (with Xcode 14.0.1 (14A400)) import SwiftUI struct ForStackOverflow: View { let spacerSize: CGFloat = 1 var body: some View…
Ryo
  • 21
  • 3
2
votes
2 answers

How to horizontally center content of horizontal ScrollView?

I have a horizontal ScrollView, and in it an HStack, like so: ScrollView(.horizontal) { HStack { Circle() .frame(width: 60, height: 60) ... } With this code, the contents of the HStack are aligned to the left of the screen, but I…
Nicolas Gimelli
  • 695
  • 7
  • 19
2
votes
2 answers

How to add elements to a HStack Using ForEach SwiftUi

Im fairly new to Swift and I'm trying to produce a HStack (that will be used in a progress bar) of element and to be able to add elements with a button. Im not sure if I should use a variable in the ForEach(1..
2
votes
3 answers

Align heights of HStack members

I want to align the heights of two HStack members. The expected outcome would be that the image has the same size as the text. The current outcome is that the image has more height than the text. This is my current setup: HStack { Text("Sample") …
ph1psG
  • 568
  • 5
  • 24
2
votes
2 answers

SwiftUI: HStack, setting custom spacing between two views in stack other than the standard spacing on HStack?

I know I can set the spacing between views in an HStack like this: HStack(spacing: 10) { .. } If I had lets say 8 views in the HStack, is there a way to set the spacing to 1 only between two consecutive views of the 8 views in the stack overriding…
zumzum
  • 17,984
  • 26
  • 111
  • 172
2
votes
1 answer

SwiftUI Wrapping HStack with Images

I am trying to make a HStack which contains x number of images and will display them in a wrapping HStack manner (i.e if only 4 of the 7 images fit on the line, then spill the 3 remaining over onto the next line). I am trying to use the library…
AAH
  • 99
  • 1
  • 10
2
votes
1 answer

SwiftUI Shape Scale Size Such that HStack size does not increase

I'm trying to make the circles fit into the HStack such that the HStack size does not increase. How can I make the circles fit without specifying a fixed frame? struct ContentView: View { var body: some View { NavigationView { …
Isaak
  • 1,107
  • 2
  • 11
  • 29
2
votes
2 answers

Result of 'HStack' initializer is unused / HStack Not Appearing in View

I'm trying to get an HStack of stars for rating (1-5) to appear in a view that I've created, but I'm getting this warning Result of 'HStack' initializer is unused and the stars aren't appearing on the view. AddMeal View Code: import…
ERACED
  • 19
  • 4
2
votes
1 answer

Drag & drop to reorder for Text without using List/Form

I have used the .gesture for dragging the piece of text. What I want to happen is the remaining letters to move to the right such that 'g' takes the first position and the remaining letters move towards the right. But I am unable to figure out how…
ItsZiaW
  • 180
  • 2
  • 14
1
2
3
10 11