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
69
votes
11 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
  • 733
  • 1
  • 7
  • 9
61
votes
4 answers

How to adjust spacing between HStack elements in SwiftUI?

I have added spacer(minLength: 5) but it takes the minLength. How 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
  • 2,963
  • 3
  • 14
  • 33
22
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
  • 15,024
  • 17
  • 92
  • 165
17
votes
2 answers

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
  • 7,430
  • 3
  • 24
  • 30
13
votes
2 answers

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
  • 26,573
  • 48
  • 165
  • 294
11
votes
3 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
  • 6,647
  • 1
  • 45
  • 88
10
votes
2 answers

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
  • 8,460
  • 5
  • 41
  • 56
9
votes
3 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
  • 9,659
  • 3
  • 46
  • 49
6
votes
5 answers

SwiftUI ScrollView horizontal RTL not working correctly

I'm trying to support RTL mode on my ios , which was built using swiftUI every is fine while doing this to change the layour direction : .environment(\.layoutDirection, .rightToLeft) Only with horizontal ScrollView , it's not work correctly when…
Ouail Bellal
  • 1,554
  • 13
  • 27
6
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,611
  • 32
  • 45
4
votes
1 answer

SwiftUI How to align child views inside HStack

I have a similar problem to this question (no answer yet): SwiftUI HStack with GeometryReader and paddings In difference my goal is to align two views inside an HStack and where the left view gets 1/3 of the available width and the right view gets…
Ali
  • 761
  • 1
  • 5
  • 24
4
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
  • 176
  • 1
  • 13
3
votes
1 answer

VSTACK google sheets function doesn't work

Suddently, the Google Sheets functions VSTACK and HSTACK don't work any more. Any Idea why? I'm in Colombia right know and the google account that I use is in Spanish. But I used to use those functions, even they have google documentation. The…
3
votes
2 answers

SwiftUI - How to center a component in a horizontal ScrollView when tapped?

I have a horizontal ScrollView, and within it an HStack. It contains multiple Subviews, rendered by a ForEach. I want to make it so that when these Subviews are tapped, they become centered vertically in the view. For example, I…
Nicolas Gimelli
  • 695
  • 7
  • 19
3
votes
1 answer

Why LazyHStack takes full height but HStack does not in SwiftUI?

Why does a LazyHStack behaves differently than an HStack regarding the height? (same for the VStack). import SwiftUI struct LazyTestView: View { var body: some View { LazyHStack { ForEach(1...10, id: \.self) { int in …
alpennec
  • 1,864
  • 3
  • 18
  • 25
1
2 3
10 11