Questions tagged [lazyvgrid]
39 questions
13
votes
1 answer
SwiftUI configure LazyVGrid with no spacing
I wanted to create a grid of cells with no spaces or smaller space just like the Photos app, is it possible with SwiftUI 2 LazyVGrid? I've tried it but there is always this space in-between columns.
In the documentation, the spacing parameter is…
randomor
- 4,353
- 3
- 37
- 63
4
votes
1 answer
How to use GeometryReader within a LazyVGrid
I'm building a grid with cards which have an image view at the top and some text at the bottom. Here is the swift UI code for the component:
struct Main: View {
var body: some View {
ScrollView {
LazyVGrid(columns:…
thexande
- 1,390
- 12
- 20
3
votes
1 answer
Center the last row in a LazyVGrid
In a LazyVGrid, I show data coming from the server (here I'm using the alphabet as an example), and my goal is to show the last row in a center instead of leading if the last row contains less than 3 items. Is it doable?
Currently, it looks like…
Harshil Patel
- 785
- 1
- 3
- 17
3
votes
1 answer
How do I correctly pass a "cell item" to a .sheet from a SwiftUI LazyVGrid?
Here is my example, and I can't tell if this is a bug or not. All my cells load correctly, but when I try to bring up the DetailView() as a sheet, the item pased in is always whatevr item is shown first in the grid (in the top left in my case here),…
Rillieux
- 267
- 3
- 15
3
votes
0 answers
LazyVGrid, List, LazyStacks don't release views from memory?
I'm playing around with the new photo picker in SwiftUI 2 and I made a simple app to show the imported images in a LazyVGrid but when scrolling down, if I imported around 150 images the app finish all the memory and it crashes (Terminated due to…
Ludyem
- 1,015
- 10
- 27
3
votes
0 answers
How to make LazyVGrid not to be lazy?
Inside my ScrollView, there is LazyVGrid view on the top of other View. After scrolling to bottom, when I scroll to top slowly, I notice that LazyVGrid view disappears for a while. Here is my snapshot (https://imgur.com/gallery/kFsgvgv)
struct…
Dscyre Scotti
- 823
- 3
- 12
2
votes
1 answer
How to make SwiftUI Text multilineTextAlignment start from Top and Center
How can I make the image and text alignment same as 3 other in SwiftUI LazyVGrid as I expected in image below?
I think the problem is how to make the text start from top if the text is multiline. In Android I can use gravity="top|center" but in…
doema
- 237
- 2
- 6
2
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
- 11,371
- 11
- 72
- 126
2
votes
0 answers
SwiftUI: Displaying variable length strings in a LazyVGrid
I'm trying to construct a vertical grid of strings that have variable lengths to be displayed side by side to each other (such as a collection of social media tags), as follows:
struct ContentView: View {
let data = ["first text",
"second…
JAHelia
- 4,684
- 14
- 52
- 102
2
votes
1 answer
SwiftUI & CoreData: How to count number of "true" booleans and display result in VGrid
I created a CoreData Entity called Event with its attributes category ( String) and isBlack (Bool). I also created a Button & a VGrid (Xcode 12 beta).
The button, upon clicked, adds and saves some entries to CoreData. I have a @FetchRequest and a…
Mike Z
- 45
- 6
1
vote
1 answer
Not able to run Grid views in swift ui
Xcode Version - 12.5
Swift Version - 5.4
code (ContentView.swift)
When I try to run this code I get and error in SceneDelegate.swift as follows
Akshay Devkate
- 23
- 4
1
vote
0 answers
Is it possible to build a simple collection of flexible Views in SwiftUI using Grid?
What I'm trying to build is really very simple and common component. Here's the design:
Here's the code that I've tried till now:
struct ContentView: View {
var tags: [String]
var body: some View {
LazyVGrid(columns:…
Frankenstein
- 13,516
- 4
- 12
- 38
1
vote
1 answer
How to create a 2 column grid with square shaped cells in SwiftUI
I'm trying to replicate this UI in SwiftUI using a Grid.
I created the cell like this.
struct MenuButton: View {
let title: String
let icon: Image
var body: some View {
Button(action: {
print(#function)
…
Isuru
- 27,485
- 56
- 174
- 278
1
vote
1 answer
Dynamically add cells to SwiftUI LazyGrid
How to dynamically add cells (not columns) to some LazyVGrid in SwiftUI?
The following code should add 1 cell by clicking the button. It compiles but doesn't work.
What I a missing?
import SwiftUI
struct GridContent: Identifiable {
var id =…
user3338488
- 61
- 6
1
vote
1 answer
SwiftUI Thread 1: Fatal error: each layout item may only occur once
This little code is showing articles from an API with 2 columns with scrollview on ArticleView. Unfortunately after the 6th loadMoreContentIfNeeded it gives me hard time with this error
Thread 1: Fatal error: each layout item may only occur once
I…
Mert Köksal
- 359
- 1
- 9