
最終效果
要求:
- Platform: iOS8.0+
- Language: Swift3.1
- Editor: Xcode8.3+
實(shí)現(xiàn):
- UITableView的橫向滾動(dòng)
看到網(wǎng)上公認(rèn)的一種比較簡(jiǎn)單的方法是旋轉(zhuǎn)tableView和cell.contentView
// tableView旋轉(zhuǎn)-90°
tableView.transform = CGAffineTransform(rotationAngle: -.pi/2)
// cell.contentView反向旋轉(zhuǎn)90°
cell.contentView.transform = CGAffineTransform(rotationAngle: .pi/2)
- 卡片式布局

1. 設(shè)置cell.contentView的`Layout Margins`均為40

2. 設(shè)置兩邊的margin視圖

3. 注意取消勾選cell和contentView的`Clip To Bounds`選項(xiàng),防止margin視圖被`裁剪`
- table view設(shè)置
tableView.isPagingEnabled = true // 分頁(yè)
tableView.rowHeight = view.bounds.width // cell高度
tableView.separatorStyle = .none // 分割線樣式
github
https://github.com/BackWorld/TableViewHorizontalScroll
如果對(duì)你有幫助,別忘了點(diǎn)個(gè)??哦。