I am developing iOS app in which i got stuck at one point.
I am using horizontal collectionView
, i want to reduce the spacing between two collectionViewCell
, i have wrote the below code snippet but it doesn't change the spacing between the cells.
.h class
@property (strong, nonatomic) IBOutlet UICollectionView *CollectnVw;
.m class
- (void)viewDidLoad{
[_CollectnVw registerNib:[UINib nibWithNibName:@"FilterCustomCell" bundle:nil] forCellWithReuseIdentifier:@"collectionViewCell"];
_CollectnVw.backgroundColor = [UIColor clearColor];
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(100, 35)];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
[_CollectnVw setCollectionViewLayout:flowLayout];
[_CollectnVw setAllowsSelection:YES];
_CollectnVw.delegate=self;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [FilterNameArr count];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collectionViewCell" forIndexPath:indexPath];
UILabel *titleLabel = (UILabel *)[cell viewWithTag:96];
[titleLabel setText:[FilterNameArr objectAtIndex:indexPath.row]];
cell.layer.borderWidth=1.0f;
cell.layer.borderColor=[UIColor blueColor].CGColor;
return cell;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionView *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
return 50; // This is the minimum inter item spacing, Doesn't changing.....
}
I am able to see my cells but spacing between the cells not changing, i want zero spacing between the cells...
please help and thanks in advance