【iOS】实现UITableView横向滚动卡片布局
2017-07-25 本文已影响494人
清無

要求:
- 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)
- 卡片式布局



- table view设置
tableView.isPagingEnabled = true // 分页
tableView.rowHeight = view.bounds.width // cell高度
tableView.separatorStyle = .none // 分割线样式
github
https://github.com/BackWorld/TableViewHorizontalScroll
如果对你有帮助,别忘了点个❤️哦。