For questions about how to lay out Swift UI elements on screen as intended. When using this tag also include the more generic [swiftui] tag where possible.
Questions tagged [swiftui-layout]
39 questions
0
votes
1 answer
How to use layoutPriority on 1 component while using maxWidth / minWidth on deprioritized component
I am trying to create a UI component where we have a horizontal cell containing a title / subtitle on the leading side.
Then at the trailing end of the component, there's an optional text (actionText), like so:
This is what I want to…

Shawn Morrison
- 35
- 4
0
votes
0 answers
Why does the list run under my tab bar when using TabView on device, but not in Simulator?
When I run this code, the list is visible behind the tab bar created by the TabView. If I comment out the Image, everything is ok.
How do I make sure the list is not visible behind the tab bar?
struct MainView: View {
var body: some View {
…

Zonker.in.Geneva
- 1,389
- 11
- 19
0
votes
1 answer
How to overlay view on top of multiple other views in a VStack in SwiftUI
In SwiftUI I currently have a VStack of views, and I'd like to put an overlay over the bottom two views, like this:
VStack {
Spacer()
Group {
centerView
Spacer()
}
.overlay(overlayedView)
}
The goal of the above layout is ensure…

wristbands
- 1,021
- 11
- 22
0
votes
0 answers
How to prevent view from being pushed by other view expanding in SwiftUI
If you have something like this. You'll see that the bottom views rectangle 1 and rectangle 2 are aligned with one another.
HStack(spacing: 0) {
Rectangle()
.fill(Color.smashFrameStartup)
…

Petesta
- 1,623
- 3
- 19
- 29
0
votes
1 answer
SwiftUI truncate content of ForEach
In the following code snippet, the red circles obviously don't fit onto the screen and therefore only the trailing part of the HStack is shown. Instead of that behavior, I want the leading text of the HStack to always be visible and truncate the…

Isaak
- 1,107
- 2
- 11
- 29
0
votes
1 answer
Looped value is showing the same result for tap
I have imported JSON for countries:
Countries.json (sample)
[
{
display_name: "France",
timezone: "placeholder",
longitude: 13.33,
latitude: 15.34
},
{
display_name:…

mitchellOcavoos
- 63
- 6
0
votes
1 answer
SwiftUI: Why isn't my view being shown off-screen as its frame suggests it should?
I have an interface where I want to be able to toggle a Side Menu and also a toolbar. The Side Menu slides in/out from the right and the Toolbar from the bottom.
I'm making it generic so it's reusable to whatever content one wants to use.
The code…

horseshoe7
- 2,745
- 2
- 35
- 49
0
votes
1 answer
Curves and Paths in SwiftUI
I am trying to create a curved path wrapped in a shape in order to attach to a tab bar but I’m having trouble get the desired look.
Here’s the look I am going for. Any ideas on how to create this shape?

Liam
- 123
- 1
- 11
-1
votes
1 answer
How to ignore parent view's padding SwiftUI
I have a VStack with multiple child views (the one with blue background). The VStack has horizontal padding. I want to have this padding set for each child, but sometimes I have exception where I want that child to reach edges of the display…

PigeonPO
- 74
- 8