在UICollectionView上面添加分割线
2015-10-10 20:32
871 查看
万能的百度,没有找到这个解决方法,我糅合了这个
点击打开链接 帖子的答案,
在函数
- (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;
}
效果如下:
点击打开链接 帖子的答案,
在函数
- (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;
}
效果如下:
相关文章推荐
- JuQueen(线段树 lazy)
- JuQueen(线段树 lazy)
- IOS-9-UIBarButtonItem导航条-添加自定义Left或者Right按钮
- EditorWindow 和MenuItem
- AndroidStuido在svn下需要忽略的文件
- iOS开发 ----- UIViewController转场动画
- UITabBarController中自定义UITabBar
- LeetCode -- Longest Consecutive Sequence
- ios之UITabBarItem显示真实自定义的图片而非颜色填充
- ubuntu中由于将用户权限修改为root导致只能使用guest进入图形化界面的解决方法
- UE4的Collision与Physics
- UIButton添加长按事件
- 使用Anemometer基于pt-query-digest将MySQL慢查询可视化
- LightOJ 1082 - Array Queries【线段树最值】
- 根据Item数动态设定ListView高度
- UIViewController没有随着设备一起旋转的原因
- 使用Volley的imageRequest加载图片实例(含listview异步加载图片错位问题)
- UITableView
- iOS开发UI篇-Quartz2D使用(绘图路径)
- UIView动画