ios - 在 collectionview 中以不同大小的网格格式显示图像
问题描述
我想在集合视图中以不同大小的网格格式显示图像,并带有加号(即+2、+3 等)。它看起来像这样...
我才知道使用UICollectionViewFlowLayout
这个可以实现。所以我参考了这个Stack Overflow question 并尝试添加这行代码。但它没有用
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
switch indexPath.item {
case 0,1:
return CGSize(width: (UIScreen.main.bounds.width - 16) / 2, height: (UIScreen.main.bounds.width - 16) / 2)
default:
return CGSize(width: (UIScreen.main.bounds.width - 32) / 3, height: (UIScreen.main.bounds.width) / 3)
}
}
此外,如果选择的图像数量是 2 或 3,那么这些图像应该像这样排列..
我怎样才能使图像看起来像那样......?
解决方案
推荐阅读
- asciidoctor - asciidoctor:如何离线提供 source-highlighter JavaScript 文件
- php - 使用 mysql codeigniter 更新图像 null
- asp.net-web-api - 使用 Camel 将消息从 ActiveMQ Artemis 发送到 Rest 服务
- mysql - sql查询获取具有多个条件的数据
- android - 使用 google 地方查找附近的位置
- javascript - 如何仅使用月份名称使用 MomentJS 设置完整日期?
- php - 将select转换为mysql php输入
- python-3.x - 从逻辑回归系数中推导出新的连续变量
- .htaccess - 如果特定参数不存在,则重定向 URL
- html - 单击汉堡图标时如何下推菜单内容?