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

76 questions
31
votes
2 answers

How to adjust spacing between HStack elements in swiftUI?

I have added spacer(minLength: 5) but it takes the minlenght can I specify the spacing between the text. I have attached a screenshot for reference I want to reduce the spacing between inner hstack. HStack…
Let's_Create
  • 1,573
  • 2
  • 8
  • 27
26
votes
6 answers

SwiftUI HStack with Wrap

Is it possible that the blue tags (which are currently truncated) are displayed completely and then it automatically makes a line break? NavigationLink(destination: GameListView()) { VStack(alignment: .leading, spacing: 5){ // Name der…
Flolle
  • 283
  • 1
  • 4
  • 9
10
votes
2 answers

SwiftUI: How to have HStack wrap children along multiple lines (like a collection view)?

I'm trying to recreate basic collection view behavior with SwiftUI: I have a number of views (e.g. photos) that are shown next to each other horizontally. When there is not enough space to show all photos on the same line, the remaining photos…
Mark
  • 5,965
  • 1
  • 37
  • 77
10
votes
1 answer

SwiftUI - Placing two pickers side-by-side in HStack does not resize pickers

My goal is to have two pickers placed side-by-side horizontally with each picker taking up half the width of the screen. Imagine a UIPickerView that fits the width of the screen and has two components of equal width - that's what I'm attempting to…
graycampbell
  • 5,620
  • 2
  • 18
  • 26
7
votes
3 answers

SwiftUI stop Divider from expanding vertically in HStack

I'm using SwiftUI to create something like an alert popup, which I present from UIKit code using UIHostingController. The view looks like this: VStack(spacing: 0) { // Some text ... HStack(spacing:0) { Button(action:…
Rob N
  • 11,371
  • 11
  • 72
  • 126
6
votes
1 answer

Load more functionality using SwiftUI

i have used ScrollView with HStack, now i need to load more data when user reached scrolling at last. var items: [Landmark] i have used array of items which i am appeding in HStack using ForEach ScrollView(showsHorizontalIndicator: false) { …
PinkeshGjr
  • 7,088
  • 5
  • 35
  • 52
5
votes
2 answers

SwiftUI: How to force a specific view in an HStack to be in the centre

Given an HStack like the following: HStack{ Text("View1") Text("Centre") Text("View2") Text("View3") } How can I force the 'Centre' view to be in the centre?
Confused Vorlon
  • 7,561
  • 1
  • 36
  • 40
5
votes
1 answer

SwiftUI position text bottom right?

Is there a better way of positioning text in SwiftUI, in the example below I am positioning the text in the bottom right corner of a ZStack, it works fine but seems long winded, am I missing a simpler way ... The orange lines are just for debugging,…
fuzzygoat
  • 25,797
  • 45
  • 159
  • 288
4
votes
1 answer

SwiftUI - Two Separate Buttons Acting As One

Xcode 11.3 (11C29). macOS 10.15.2. In the SwiftUI View below there are two buttons. One prints "OK" and the other prints "Cancel". However, regardless of whichever button is pressed, both print statements are executed. Why is that? (I assume…
Vince O'Sullivan
  • 2,403
  • 25
  • 40
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
  • 9,072
  • 17
  • 84
  • 170
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
  • 223
  • 3
  • 14
2
votes
1 answer

SwiftUI layers in HStack

When I drag the rectangle to the left, the symbol is under the rectangle but on the right the symbol is over the rectangle, when I drag it to the right. I know, that the hierarchy of the HStack decides the layer but if I would do the right symbol…
beab
  • 23
  • 6
2
votes
1 answer

Have 0th item in SwiftUI auto selected

I have data loaded into an HStack that is in a Scroll View in SwiftUI. Right now I have it coded where a user can tap on one of those items and have it selected. I'd like for the 0th item to already be selected upon load. import SwiftUI import…
Luke Irvin
  • 933
  • 1
  • 14
  • 34
2
votes
0 answers

List cell load animation one after another in SwiftUI

I need to animate the load of the List rows. When the list reloads the data I need the rows get in from the left one after another. How can I achieve this?
Ravindra_Bhati
  • 803
  • 7
  • 23
2
votes
2 answers

SwiftUI HStack with uneven sized elements

Desired output Looking for a way to split an HStack in uneven elements, one taking over 1/2 of the screen and the other two 1/4 of the screen (see attachment). Code: struct MyCategoryRow: View { var body: some View { VStack(alignment:…
sugar2code
  • 146
  • 12
1
2 3 4 5 6