在UICollectionView上面添加分割线

万能的百度,没有找到这个解决方法,我糅合了这个 点击打开链接 帖子的答案,

在函数

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

里增加了以下代码:

    CGSize contentSize = self.clevVideo.contentSize;
    if(didAddSperateVerticalLine == NO) {
        UIView *verticalLine = [[UIView alloc]initWithFrame:CGRectMake(contentSize.width * 0.5 - 0.5, 0, 1, contentSize.height - 8)];
        verticalLine.backgroundColor = [UIColor lightGrayColor];//colorWithRed:225/225.0f green:227/225.0f blue:233/225.0f alpha:1.0];
        verticalLine.alpha = 0.35;
        [self.clevVideo addSubview:verticalLine];
        didAddSperateVerticalLine = YES;
    }
    
    UIView *horizontalLine = [[UIView alloc]initWithFrame:CGRectMake(0, (20 + cell.frame.size.height) * indexPath.row , contentSize.width, 1)];//每一个cell的framee是 17.00, 10.00, 160.00, 160.00  ,
    NSLog(@"%ld, =>  %.2f, %.2f, %.2f, %.2f, ", indexPath.row, horizontalLine.frame.origin.x, horizontalLine.frame.origin.y, horizontalLine.frame.size.width, horizontalLine.frame.size.height);
    horizontalLine.backgroundColor = [UIColor lightGrayColor];
    horizontalLine.alpha = 0.35;
    [self.clevVideo addSubview:horizontalLine];

    return cell;

}

效果如下:


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值