![](https://img.haomeiwen.com/i1334681/c7b1be638e1769fb.gif)
要求:
- Platform: iOS8.0+
- Language: Swift3.1
- Editor: Xcode8.3+
实现:
- UITableView的横向滚动
看到网上公认的一种比较简单的方法是旋转tableView和cell.contentView
// tableView旋转-90°
tableView.transform = CGAffineTransform(rotationAngle: -.pi/2)
// cell.contentView反向旋转90°
cell.contentView.transform = CGAffineTransform(rotationAngle: .pi/2)
- 卡片式布局
![](https://img.haomeiwen.com/i1334681/89b532dd0fa7e3eb.png)
![](https://img.haomeiwen.com/i1334681/197929f1bc96c3d1.png)
![](https://img.haomeiwen.com/i1334681/081545574fb9909f.png)
- table view设置
tableView.isPagingEnabled = true // 分页
tableView.rowHeight = view.bounds.width // cell高度
tableView.separatorStyle = .none // 分割线样式
github
https://github.com/BackWorld/TableViewHorizontalScroll
如果对你有帮助,别忘了点个❤️哦。
网友评论