lazyvgrid

SwiftUI grid with column that fits content?

安稳与你 提交于 2021-01-28 17:02:33
问题 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 with auto layout. SwiftUI 2020 has LazyVGrid but the only ways I see to set the column sizes use hardcoded numbers. Do they not understand what a problem causes with multiple languages and user-adjustable font sizes? 回答1: It is not so complex if to

How do I correctly pass a “cell item” to a .sheet from a SwiftUI LazyVGrid?

浪子不回头ぞ 提交于 2020-11-25 03:40:33
问题 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), NOT the "cell" that was tapped. So, why is the item from ForEach loop correctly populating the cells, but not being passed to the .sheet via the button? import SwiftUI let columnCount: Int = 11 let gridSpacing: CGFloat = 1 struct GridView: View {