UICollectionView实现水平滑动 pagingEnabled分页偏移问题

创建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 
- (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开发之路》)