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
1
vote
1 answer

How to alternate centerX auto layout constraint in SwiftUI

I want to adjust my view like this to make an element align horizontally center of its parent and lead another view to that. I implement this view with auto layout simply like this. consumeLabel.centerXAnchor.constraint(equalTo:…
1
vote
1 answer

SwiftUI - Xcode - Inferring type not possible for VStack

I am trying to create a simple master/detail app in Xcode. I want that the detail view is struct EditingView: View { var body: some View { var mainVertical: VStack = VStack() //error here { var previewArea:…
P5music
  • 3,197
  • 2
  • 32
  • 81
1
vote
1 answer

In SwiftUI Picker expands to occupy entire space inside a HStack

I have a Text and Picker in HStack separated by Spacer. What I want is that the Spacer should should occupy maximum space between picker and text so that the Text and Picker are not the extreme ends of the HStack but, the picker expands to occupy…
Rakesh.P
  • 183
  • 1
  • 2
  • 11
1
vote
1 answer

An apropriate way to create a Table in SwiftUI

From what I understand there is no dedicated table view class for use in SwiftUI. What is the best way to create such a table yourself? In fact, I am looking for something a bit different for a weekly schedule view. I am trying to build a view such…
RT.
  • 423
  • 3
  • 12
1
vote
2 answers

SwiftUI Grid Layout

I'm trying to achieve the following grid layout with SwiftUI but not quite sure on the best approach. My code is below and it's not quite getting what I want and also seems hacky to have many nested stacks VStack { VStack…
CIB
  • 535
  • 1
  • 12
  • 35
1
vote
1 answer

Stopping Navigation Controller? from Appearing When Scrolling to the Bottom

I have four horizontal stacks (HStack) inside ScrollView and VStack. And I have a pair of ZStack things inside each horizontal stack (HStack). The following is my code. import SwiftUI struct ContentView: View { var body: some View { …
El Tomato
  • 6,479
  • 6
  • 46
  • 75
1
vote
1 answer

SwiftUI HStack won't move to the very top?

I have an Hstack with two components. One is a drop-down menu, and the other is a nav link to "forgot password" page. I can't figure out why it won't go all the way to the top of the page. I've tried inserting Spacer() on the very bottom (but…
1
vote
1 answer

Linear Color Gradient to items in HStack?

Is there a way in SwiftUI to add a gradient color to all items in an HStack. You can apply an individual Color to both the HStack .background and .foregroundColor But because LinearGradient is a struct that conforms to View you can't pass it to…
fuzzygoat
  • 26,573
  • 48
  • 165
  • 294
1
vote
1 answer

how to create a fit HStack with equal space between it's object

I wanna create an HStack with levitating space between objects, but equal between each one and also it must fit on horizontal, Some of like that I used Spacer() between objects, like that HStack { Text("Object1") Spacer() …
mohsen
  • 4,698
  • 1
  • 33
  • 54
1
vote
0 answers

TextField Error: Reference to property '$...' in closure requires explicit 'self.' to make capture semantics explicit

I want to get text from a textfield. My var is Entfernung: @State var entfernung = "" And here is my HStack where the TextField is in: HStack{ Text(LocalizedStringKey("entfernung")).font(.title).bold().padding(.leading,…
1
vote
4 answers

SwiftUI how would I retrieve the size of an HStack object in Swift UI

I am trying to figure out how to retrieve the size of this HStack to auto calculate dividing the frame into 3. The plan is to set a colored bar below the active screen header, please see picture example below. VStack{ HStack{ …
bain
  • 335
  • 1
  • 6
  • 17
1
vote
0 answers

Migrate UITableView's and UICollectionView's Xib in SwiftUI

I have converted my existing Xib UI in SwiftUI. Is it possible to use SwiftUI in existing UITableView and UICollectionView? Here is the code i have done in SwiftUI struct LandmarkList: View { @EnvironmentObject var userData: UserData var…
PinkeshGjr
  • 8,460
  • 5
  • 41
  • 56
0
votes
2 answers

How to apply the same font size to multiple Texts within an HStack and size the HStack to fit its parent?

I have an HStack with three Texts: HStack { Text("Hey") Text(".") Text("What's up?") } All I want is the HStack to fill the available space of its parent container under the constraint that all three Texts have the same font size in the…
Mischa
  • 15,816
  • 8
  • 59
  • 117
0
votes
3 answers

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 { ZStack { Color(.red) …
Alejandro
  • 5
  • 3
0
votes
1 answer

Check size of view before adding to Stack with max width

I want to achieve a "chip" view where the first chips take a max width of 2/3 of the screen. If there are more chips a count like +2 should be displayed. To achieve this I was thinking to kind of truncate an HStack. However, I would need to able to…
gpichler
  • 2,181
  • 2
  • 27
  • 52