Questions tagged [lazyhgrid]

15 questions
5
votes
1 answer

SwiftUI - Dynamic LazyHGrid row height

I'm creating vertical layout which has scrollable horizontal LazyHGrid in it. The problem is that views in LazyHGrid can have different heights (primarly because of dynamic text lines) but the grid always calculates height of itself based on first…
Robert Dresler
  • 10,580
  • 2
  • 22
  • 40
4
votes
2 answers

Why is LazyHGrid not as high as its items?

I've got a LazyHGrid that shows multiple Text views in one row. That LazyHGrid is inside a VStack. However, the LazyHGrid is higher than it needs to be. What causes the extra space? struct ContentView: View { let rows = [GridItem()] var…
WalterBeiter
  • 2,021
  • 3
  • 23
  • 48
4
votes
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
  • 15,732
  • 4
  • 22
  • 47
4
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
  • 503
  • 4
  • 7
4
votes
1 answer

SwiftUI: How to make GridItem pushing out to fill the available space

I would like to create a grid with 24 Items in 4 rows, so each row should have 6 items. All items should be equally sized but fill the whole space available, no matter what device the grid is rendered on. I already achieved a flexible height for the…
LukeSideWalker
  • 7,399
  • 2
  • 37
  • 45
3
votes
1 answer

Building a lazy grid with rows and columns - SwiftUI

I am wanting to create a view in my app which acts basically as a table. I believe a lazy grid is the best way to do this in iOS 14, I'm just not sure what I am doing with them. The sort of table I want to create is pictured below: Each of the rows…
benpomeroy9
  • 375
  • 5
  • 21
2
votes
1 answer

Pinned sections on top of the view in LazyHGrid

I have searched a lot of this issue, How to achieve pinning the section on top of the view while we have horizontal scrolling in LazyHGrid similar to Native Emoji keyboard, we might have a workaround? Updated ScrollView(.horizontal) { …
SimpleojbC
  • 127
  • 2
  • 14
2
votes
0 answers

How to show page indicator for LazyHGrid in Swift UI

I want to achieve the pagination and page indicator with dots as in Swift (UIPageControl) in swift UI. I am using a lazy H grid, and a button inside a for Each loop to get the horizontal grid. How to add the page indicator to LazyHgrid to achieve…
abinbabu
  • 43
  • 8
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
1 answer

How to eliminate spacing around LazyHGrid items?

I've set the spacing on the LazyHGrid and the GridItems to 0, yet there is still spacing in the vertical direction. Why is that? How do I eliminate that spacing? struct ContentView: View { let strs: [String] = ["aa", "", "bbbb"] let…
Rob N
  • 15,024
  • 17
  • 92
  • 165
1
vote
2 answers

Problem with formatting LazyHGrid - SwiftUI

I am trying to create a basic lazyHGrid but after looking at a couple of different tutorials online I still can't manage to build it properly. I am trying to make a grid that is filled with rectangles with symbols and text inside those rectangles.…
spoax
  • 471
  • 9
  • 29
0
votes
1 answer

SwiftUI - grid / table with column headings

I'm trying to achieve a design which essentially has the following layout: So I need column headings for this table or grid view. The second column does not need a heading. This seems like a job for a LazyVGrid or LazyHGrid, however I can't seem to…
DevB1
  • 1,235
  • 3
  • 17
  • 43
0
votes
0 answers

Wrong selection with LazyHGrid SwiftUI

Hi all I have a problem with selecting cells in a LazyHGrid using SwiftUI In the TimePickerGridView.swift I create a horizontal list with times that the user can select. To manage cell selection I use @State private var selectedItem: Int =…
kAiN
  • 2,559
  • 1
  • 26
  • 54
0
votes
1 answer

Preselection of an item on LazyHGrid

Hi everyone I'm working with a LazyHGrid The grid shows 19 cells divided on 2 lines and their contents are times that the user can select. I have a problem with the preselection, i.e. I would like that when the horizontal grid is shown, a…
kAiN
  • 2,559
  • 1
  • 26
  • 54
0
votes
1 answer

SwiftUI How do I record the index of the grid item that is currently being displayed on CollectionView?

I am trying to have a scrolling horizontal list of items, where each item takes up almost the full screen width (UIScreen.main.bounds.width - 50). There should be just enough of the next item visible for the user to know there is something to…
Crystal
  • 46
  • 7