Questions tagged [lazyvgrid]
131 questions
1
vote
0 answers
iOS SwiftUI - LazyVGrid spacing inconsistent, not filling correctly
I'm showing 500 items with different height:
let columns = [
GridItem(.flexible()),
GridItem(.flexible())
]
let randHeight: [CGFloat] = [30, 60, 90]
LazyVGrid(columns: columns, spacing: 20) {
ForEach(memes, id:…

user19559647
- 191
- 1
- 1
- 7
1
vote
0 answers
SwiftUI - grid with irregular rows
I'm trying to create the following grid format in SwiftUI:
For context, this is a row in a basket. I'm trying to use a LazyVGrid and so far have the following column layout defined:
let columns = [
GridItem(.flexible()),
…

DevB1
- 1,235
- 3
- 17
- 43
1
vote
1 answer
How to make swiftui lazyvgrid multiple columns
I want to make a lazyvgrid with multiple columns as bellow. Large size items can be aligned with two smaller sizes.
My code is as bellow:
struct ContentView: View {
let paddingLeft: CGFloat = 22.0
var body: some View {
let…

mars
- 109
- 5
- 21
1
vote
0 answers
SwiftUI grid - align center leading
I have the following column structure defined for a VGrid:
let columns = [
GridItem(.flexible()),
GridItem(.flexible(), alignment: .topLeading),
GridItem(.flexible(), alignment: .topTrailing),
GridItem(.flexible(), alignment:…

DevB1
- 1,235
- 3
- 17
- 43
1
vote
1 answer
SwiftUI: Animate LazyVGrid layout change when window is resized
In a MacOS app, I have a LazyVGrid. As we resize the window width, it adapts the layout, i.e. rearranges its items.
I would like to animate these layout changes. Afaik the recommended ways are withAnimation and .animation(Animation?, value:…

bzyr
- 289
- 1
- 11
1
vote
0 answers
LazyVGrid miss handles the tap
I am using the LazyVGrid in my app and a faced such problem
There are two columns in the grid and that is handling the tap in the wrong place
On the screenshot, red arrows - places of the click
I used to think that would open the MacBookAir's card,…

Daniel Pustotin
- 237
- 1
- 9
1
vote
0 answers
SwiftUI LazyVGrid Adaptive GridItem
Pretty newbe question I guess.
Target: A Grid that fills as much horizontal space as possible, that grows vertically.
My approach is using a LazyVGrid with a single GridItem(.adaptive(minimum: 40)).
However, for some reason all LazyVGrid children…

boring_ape
- 59
- 3
1
vote
1 answer
SwiftUI: `onDrop` overlay not going away in LazyVGrid?
I am testing out Asperi's great answer to reordering cells:
SwiftUI | Using onDrag and onDrop to reorder Items within one single LazyGrid?
The issue I have is the overlay does not reset when I simply enter drag mode and then drop in place, see cell…

zumzum
- 17,984
- 26
- 111
- 172
1
vote
1 answer
How to make a lazyvgrid/ lazyhgrid scroll horizontally maintaining its appearance?
I’m trying to create a lazyvgrid which has 1 row and scrolls horizontally but i must be missing something since everything I try messes up my layout.
What i want to achieve:
A grid like this (with just 1 row) that is able to scroll…

crost
- 165
- 1
- 13
1
vote
2 answers
Improve performance of LazyVGrid of images from Core Data
I am storing images in Core Data as binary data, and showing them in another view via a LazyVGrid to replicate a CollectionView in UIKit. However, performance seems to be really choppy/poor on scroll and was wondering if there's any improvements…

aashah7
- 2,075
- 1
- 17
- 24
1
vote
1 answer
How to connect LazyVGrid cells with the corresponding full screen images in a TabView (Xcode 13, iOS15)
I'm having a hard time matching the correct grid cell when zooming out from the corresponding tab.
Just starting to learn and I should definitely go through a few more tutorials. If you want to lend a hand here, thank you in advance.
This is the…

Neurythmic
- 25
- 5
1
vote
1 answer
How to connect 50 thumbnails with the corresponding full size wallpapers in a LazyVGrid? (Xcode 13, iOS15)
Using the full, 2960x1440 wallpapers with LazyVGrid is not an option, as it leads to unsatisfactory performance, even on an iPhone 12 Pro.
All assets are stored in the asset catalog.
These are the Models:
struct Thumbnail: Identifiable {
var id…

Neurythmic
- 25
- 5
1
vote
1 answer
LazyVGrid inside a Picker, using SwiftUI
In the code below the picker works great, however the LazyVGrid appears as one column only (should be three columns, as indicated in pickColorTable var).
var pickColorTable:[GridItem] = Array(repeating: .init(.flexible(), spacing: 5), count:…

L. Puzer
- 55
- 5
1
vote
0 answers
How do you keep 'fullScreenISPresented' from dismissing itself when the screen rotates?
I have a LazyVGrid with a layout count: 2 when in portrait, and court: 3 when in landscape, in a scrollview. I use a ternary to change the count. Problem is when I scroll down than select a cell, when the model slides up and I rotate, the view…

TheManOfSteell
- 105
- 9
1
vote
1 answer
DetailView only calls on first item in array when using LazyVGrid
I had a list that I could add items to and when I click on them it opened up the correct detail view. I recently swapped the list out for LazyVGrid but when I click on a grid item, the detail view only calls on the first item in the array.
This is…

Lloyd English
- 115
- 8