万能的百度,没有找到这个解决方法,我糅合了这个 点击打开链接 帖子的答案,
在函数
- (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;
}
效果如下: