iOS UICollectionView去除多余分割线
来源:互联网 发布:cctv网络电视播放器 编辑:程序博客网 时间:2024/06/06 05:22
出现原因: 浮点数除法导致cell在布局时frame有误差。
解决办法:
class MyCollectionViewFlowLayout: UICollectionViewFlowLayout { override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { let attributes = super.layoutAttributesForElements(in: rect) guard attributes != nil else { return nil } for i in 1..<attributes!.count { let current = attributes![i] let original = attributes![i-1].frame.maxX if original + current.frame.width <= collectionViewContentSize.width { current.frame.origin.x = original } } return attributes }}然后把原来你声明的 layout 在声明时写成这样: let layout = MyCollectionViewFlowLayout()其余代码一下不要动!!!OK啦!
阅读全文
0 0
- iOS UICollectionView去除多余分割线
- iOS UITableView 去除多余分割线
- ios 去除UITableView多余分割线
- 去除UITableView多余分割线
- 去除UITableView多余分割线
- iOS之去除UITableView底部多余行及分割线
- UITableView 去除多余的分割线
- tableview去除多余分割线问题
- 去除tableView多余的分割线
- UITableView 的多余分割线的去除
- iOS小技巧-UITableView去除底部多余的分割线方法以及设置分割线风格和颜色
- iOS之一句话去除UITableView底部多余行及分割线
- iOS UITableView 隐藏多余分割线
- iOS tableView 隐藏多余分割线
- 一句话去除UITableView底部多余行及分割线
- 一句话去除UITableView底部多余行及分割线
- swift 去除tableview 中多余的分割线
- 去除UITableView底部多余行及分割线
- codeforces 849A Odds and Ends
- HDOJ HDU 1009 FatMouse' Trade
- WOJ1088-从1开始的N个连续自然数的M次方之和
- tcp/ip客户端临时端口
- auto_ptr源码解析以及例子 --auto_ptr_ref
- iOS UICollectionView去除多余分割线
- ajax乱码问题
- Java知识(异常)
- Git
- A
- 【JZOJ5342】【NOIP2017模拟9.2A组】赤壁情
- matlab2c使用c++实现matlab函数系列教程-perms函数
- 平衡二叉树
- CodeForces