当前位置:网站首页>SwiftUI * Grid
SwiftUI * Grid
2022-08-09 02:45:00 【HumorousGhost】
Grid 是一种对应 UICollectionView 的视图,分为 LazyVGrid 和 LazyHGrid 两种 Grid 控件。
基本用法
ScrollView {
LazyVGrid(columns: [
GridItem(.fixed(75.fit()), spacing: spacing),
GridItem(.fixed(75.fit()), spacing: spacing),
GridItem(.fixed(75.fit()), spacing: spacing),
GridItem(.fixed(75.fit()), spacing: spacing)
], alignment: .leading, spacing: 16.fit()) {
ForEach(0...imageList.count, id: \.self) {
index in
imageItem(imageList[index])
}
}
.padding(.horizontal, 16.fit())
}
- 首先
Grid需要配合Scrollview使用,不然没有滚动的功能 LazyVGrid与LazyHGrid可以混合使用,即上面代码中可以将imageItem()替换使用LazyHGrid控件。
GridItem
GridItem 是用于确定 Grid 的大小以及对下一个 Item 的距离的,将其用数组包裹,代表LazyVGrid 的列数或 LazyHGrid 的行数
public init(_ size: GridItem.Size = .flexible(), spacing: CGFloat? = nil, alignment: Alignment? = nil)
这个框架的文档比较少,目前并不清楚这个控件是否有重用机制
但猜测是没有重用机制的,因为 ScrollView 是没有重用机制的,而 Grid 脱离 ScrollView 又没有滚动功能,因此猜测 Grid 没有重用机制,但有懒加载机制。
边栏推荐
- Recently, I have seen a lot of people who want to study by themselves or enroll in classes but don’t know how to choose. I will tell you about it today.
- 【元胞自动机】基于元胞自动机模拟社会力因素下的灾害人员疏散应急仿真附matlab代码
- Open3D 随机采样
- 16.flink 自定义KeySelector
- opencv在图像上长按左键画矩形单击右键清除
- spark RDD转换算子 sample
- Maya engine modeling
- Likou Brush Question Record 3.1-----977. Square of ordered array
- YOLOV1详解——Pytorch版
- Financial Industry Software Testing Interview Questions (with Answers) | Getting Started Guide
猜你喜欢
随机推荐
数字 01 Vivado2018.2安装及实操
20220524搜索和排序:搜索二维矩阵II
【洛谷】P2613 【模板】有理数取余
Likou Brush Question Record 1.5-----367. Valid perfect squares
1261. 在受污染的二叉树中查找元素
工作小计 rtcp的length和网络字节序
【物理应用】基于El-centro地震波作用下隔震与非隔震支座下的顶层位移、速度、加速度的对比情况附matlab代码
【AspNetCore】实现JWT(使用Microsoft.AspNetCore.Authentication.JwtBearer)
[ANT]apache ant 安装说明
危化企业双预防机制数字化建设工作要求
php过滤特殊字符(仅保留中文、字母、数字、下划线)
gpio子系统和pinctrl子系统(中)
gpio子系统和pinctrl子系统(下)
Flume (四) --------- Flume 企业开发案例
旋转霓虹圆圈
目标检测中mAP计算以及源码解析
gpio子系统和pinctrl子系统(上)
What are the most popular automated testing tools in 2022?The most complete and most detailed of the entire network is here
从0开始搭建自动化测试框架之PO分层架构
数仓第一篇:基础架构









