应用 UICollectionView 实现上面的成果

路径 1,

简略间接, custom UICollection View Layout ,

横着码


路径 2,

UICollectionViewFlowLayout + UICollection View 的宽度管制

这样 layout 下,

    func doLayout(){        collect.snp.makeConstraints { (m) in            m.top.equalToSuperview().offset(95)            m.leading.equalTo(title)            m.height.equalTo(40)            // item width * 3 + spacing * 2            m.width.equalTo(80 * 3 + 33)        }            }