ios - 如何使用 swift 4 显示这样的 collectionView?
问题描述
collectionView
您好,我想像上面的图片一样显示多张图片。我可以在 的帮助下显示两行和三列UICollectionViewDelegateFlowLayout
,但无法做到这一点。非常感谢您的帮助。
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
switch indexPath.item {
case 0,1:
return CGSize(width: (UIScreen.main.bounds.width - 4) / 2, height: (UIScreen.main.bounds.width - 4) / 2)
default:
return CGSize(width: (UIScreen.main.bounds.width - 6) / 3, height: (UIScreen.main.bounds.width) / 3)
}
}
解决方案
推荐阅读
- reactjs - Aws Mobile Hub:将前端与后端分开
- javascript - overflow-x 滚动属性适用于桌面,但不适用于手机
- mysql - Docker 中的多个 MariaDB 数据库
- apache-kafka - 在 kafka broker 中添加压缩会有什么影响
- symfony - 在 Symfony 3 的 SQLFilter 中获取用户
- java - 我只能访问列表中的第一项
- javascript - ionic2- 动态改变离子卡的内容
- java - Button.findViewById 与 Button = findViewById
- perl - 哈希排序哈希的元素限制
- max - 契约匹配规则,最小值和最大值