cells in UICollectionview can be of same Size or different sizes, so we use the flow layout. UICollectionViewFlowLayout manage items into a grid with header and footer view for every section.
Here we define the flow layout--
-(void)viewDidLoad
{
[super viewDidLoad];
[self.collectionView registerClass:[CellClass class] forCellWithReuseIdentifier:@"identifier"];
self.collectionView.backgroundColor = [UIColor clearColor];
// Configure flow layout
self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
[self.flowLayout setItemSize:CGSizeMake(width, height)];
[self.flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
self.flowLayout.minimumInteritemSpacing = 0.0f;
[self.collectionView setCollectionViewLayout:self.flowLayout];
self.collectionView.bounces = YES;
[self.collectionView setShowsHorizontalScrollIndicator:NO];
[self.collectionView setShowsVerticalScrollIndicator:NO];
}
Here flow layout is the property of UICollectionviewFlowLayout. The method below sets the spacing between sections within the collection view.
- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(0, 0, 0, 0);
}
0 Comment(s)