Search code examples
iosobjective-ccollectionview

How to remove bottom border line with transparent background in my UICollectionView cell?


enter image description here

I tried to remove CollectionView Cell bottom border but no luck. As attached is my sample code:-

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *gridcell = nil;

    MenuDetail_Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:MenuDetail_CellID forIndexPath:indexPath];

    cell.layoutMargins = UIEdgeInsetsZero;
    cell.layer.borderWidth = 0;
    cell.clipsToBounds = YES;
    cell.contentView.layer.borderWidth = 0.0;
    cell.contentView.layer.borderColor = [UIColor clearColor].CGColor;
    cell.contentView.layer.masksToBounds = NO;

    cell.strMenuImage = self.imageArray[indexPath.row];
    cell.strMenuTitle = self.titleArray[indexPath.row];
    gridcell = cell;
    return gridcell;
}


- (UICollectionView *)collectionView
{
    if (!_collectionView) {

        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];

        _collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.delaysContentTouches = NO;


            _collectionView.frame = CGRectMake(0, DCTopNavH, ScreenW, ScreenH  - DCBottomTabH);

        _collectionView.showsVerticalScrollIndicator = NO;

        //Cell
        [_collectionView registerClass:[MenuDetail_Cell class] forCellWithReuseIdentifier:MenuDetail_CellID];


        [self.view addSubview:_collectionView];
    }
    return _collectionView;
}

Even I tried to apply minimumLineSpacingForSectionAtIndex but still the same. Any idea? Sorry for my stupid mistake if any. Thank you.


Solution

  • UICollectionView do not have a separator like UITableView

    It should be in your code somewhere, check out your storyboard of MenuDetail_Cell class