我想制作一个看起来像这样的UICollectionView
:
[ - - - - - 0 - - - - - ] -> Scrolls Horizontally
[1][2][3][4][5][6][7][8] -> Scrolls Horizontally
怎么做?
我不想将UICollectionView
放在UITableViewCell
中。
答案 0 :(得分:0)
让您的子类继承CollectionViewFlowLayoutDelegate
协议
func collectionView(collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let size = CGSize(width: defaultWidth, height: collectionView.height / 2)
//The important thing here is the height of your item is half the height of collectionView and then your flowlayout will start to put them on top of eachother.
// Also make sure that height accounts for section and content insets
return size
}
然后在viewDidLoad()
中确保将collectionView的滚动属性设置为仅水平滚动。