Questions tagged [swiftui-layout]

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.

39 questions
13
votes
2 answers

How could I use a SwiftUI LazyVGrid to create a staggered grid?

I'm trying to implement a view that contains a LazyVGrid of staggered images in a grid- as seen in the below Pinterest feed: I am aware of the WaterfallGird library but I was wondering if there would be a way to implement this functionality with a…
mstv2020
  • 143
  • 2
  • 6
4
votes
0 answers

SwiftUI: LazyVGrid not refreshing while scrolling

I have a LazyVGrid that displays search results, as I type characters in the search field, I perform CoreData fetch requests and update a @Published property. Problem: LazyVGrid updates results as expected EXCEPT if it is currently scrolling: in…
3
votes
1 answer

Is there any way to stop a single-line of swiftUI grid items jumping in width?

Items inside a SwiftUI LazyVGrid shrink to their minWidth (80 points in my example below) when the grid view expands enough to fit another column. This is visually expected when there are multiple rows: However, when there's only one row, this is…
jeff-h
  • 2,184
  • 1
  • 22
  • 33
3
votes
1 answer

SwiftUI How to Fade an Image out from the bottom Edge

Basically what Im trying to achieve is this: To fade an image out from the top to bottom. I tried to do it with overlays but it simply does not look good
Just A Question
  • 423
  • 6
  • 21
3
votes
1 answer

How to line up bottom text for child view in VStack

I have the following code which produces the following output. var body: some View { VStack(spacing: 0) { HStack(spacing: 0) { Rectangle() .fill(Color.green) .overlay( …
Petesta
  • 1,623
  • 3
  • 19
  • 29
3
votes
2 answers

Padding, offset, or position in SwiftUI

I’m trying to position a circle to have its center sitting on top of a rectangle like this. The diameter of the circle doesn't have to be the same width as the rectangle. What I’m trying to understand is what is the best and most practical way to…
Petesta
  • 1,623
  • 3
  • 19
  • 29
3
votes
1 answer

SwiftUI grid with column that fits content?

Is this layout possible with SwiftUI? I want the first column to wrap the size of the labels, so in this case it will be just big enough to show "Bigger Label:". Then give the rest of the space to the second column. This layout is pretty simple…
Rob N
  • 15,024
  • 17
  • 92
  • 165
2
votes
0 answers

How to remove the space from top of the list

I have a swiftui app. I want to remove the space that is automatically created on the top of the list, but without using the .listStyle(PlainListStyle()). var body: some View { VStack{ Text("HELLO") List{ …
2
votes
1 answer

SwiftUI Segmented picker inside Navigation Bar and below navigation title

What Im trying to achieve is to have a segmented picker inside the navigation bar, but below the title of the navigation bar while still having the collapse animation. For example instead of the search, I need a segmented…
2
votes
0 answers

How to remove bottom default padding from List view in SwiftUI

I'm trying to remove the bottom padding on a List view when another view is being defined after it so that the List view is sitting on top of the other one. Not overlaying. There seems to be some extra space created from the List and I'm not sure…
Petesta
  • 1,623
  • 3
  • 19
  • 29
2
votes
3 answers

How to have 2x2 made of squares fit screen in SwiftUI

I'm trying to create a 2x2 grid through either VStacks/HStacks or LazyVGrid to have the squares on each row fit the screen. For example, the first and second squares each take up half the width of the screen and based on that length, that'll…
Petesta
  • 1,623
  • 3
  • 19
  • 29
2
votes
2 answers

SwiftUI content gets cut off on smaller iPhone screens

I'm new to SwiftUI, so I'm following a tutorial to get familiar with it. However, my app's content is getting cut off on smaller screens (both vertically and horizontally). How can I prevent this from happening? Here's my code: EDIT: I have added…
wristbands
  • 1,021
  • 11
  • 22
2
votes
1 answer

Is there support for something like TimePicker (Hours, Mins, Secs) in SwiftUI?

I'm trying to achieve something like iOS Timer App time picker control: I've investigated the DatePicker, but it doesnt have seconds view.
devfreak
  • 1,201
  • 2
  • 17
  • 27
2
votes
1 answer

How do I change the fixed size of a Lazy Grid GridItem in response to Dynamic Text size changes?

The code below is using a LazyVGrid to implement layout of my controls such that everything lines up like this: Particularly, the sliders' ends all align and the symbols are centre-aligned to each other. I have worked out how to size the GridItems…
zkarj
  • 657
  • 9
  • 23
1
vote
2 answers

how to use custom alignmentGuide in ZStack

I want to use alignmentGuide to align center a Text view in ZStack to implement view as bellow, blue block is align traling, Text "abc" and "123" is align center of view. My code is as bellow: extension HorizontalAlignment { private enum…
mars
  • 109
  • 5
  • 21
1
2 3