创建UICollectionViewFlowLayout
要设置flowLayout.minimumLineSpacing = 0.000001f;
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumLineSpacing = 0.000001f;
//flowLayout.minimumInteritemSpacing = 20;
//flowLayout.itemSize = CGSizeMake(YCScreenWidth, YCScreenHeight);
flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;代理方法
#pragma mark <UICollectionViewDelegateFlowLayout>
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(self.bounds.size.width, self.bounds.size.height);
}类似解决UITableView分组 组头视图默认高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0.000001f;
}
本文介绍如何在iOS开发中使用UICollectionViewFlowLayout进行布局配置,通过设置minimumLineSpacing实现几乎无缝的水平滚动效果,并提供UICollectionViewDelegateFlowLayout代理方法的具体实现。
8037

被折叠的 条评论
为什么被折叠?



