iOS UICollectionView与UITableView
// 初始化瀑布流
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(150,120)]; //设置每个cell显示数据的宽和高必须
flowLayout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
flowLayout.minimumInteritemSpacing = 0;
flowLayout.minimumLineSpacing = 0;
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; //水平滑动
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical]; //控制滑动分页用
self.collectionView = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
[self.view addSubview:self.collectionView];
self.collectionView.backgroundColor = [UIColor whiteColor];
[self.collectionView registerClass:[MyCell class] forCellWithReuseIdentifier:@"COllectioncell"];
[self.collectionView setDataSource:self];
[self.collectionView setDelegate:self];
[self.view addSubview:self.collectionView];
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步