如何在UICollectionView单元格中删除具有透明背景的底部边框线?

时间:2018-10-03 10:20:30

标签: ios objective-c collectionview

enter image description here

我试图删除CollectionView Cell底部边框,但是没有运气。 随附的是我的示例代码:-

- (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;
}

即使我尝试应用minimumLineSpacingForSectionAtIndex,但还是一样。 任何想法?对不起,如果有我的愚蠢错误。谢谢。

1 个答案:

答案 0 :(得分:1)

UICollectionView没有像UITableView这样的分隔符

它应该在您代码中的某个地方,查看MenuDetail_Cell类的故事板