我在我的視圖中有多個UICollectionView
控件。每個人都有不同數量的項目,有些人有足夠的空間來填充屏幕的寬度,但其中一些只有少數不能滿足屏幕寬度的項目。因爲我想在第二組的UICollectionView
小號水平居中內容:不同的插入不同的UICollectionView在同一個XIB
此功能設置爲UICollectionView
佈局:
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
var cellWidth : CGFloat = 110
var numberOfCells = floor(self.view.frame.size.width/cellWidth)
var edgeInsets = (self.view.frame.size.width - (numberOfCells * cellWidth))/(numberOfCells + 1)
return UIEdgeInsetsMake(0, edgeInsets, 0, edgeInsets)
}
我的問題是如何能得到細胞每個UICollectionView
的寬度?
你想保持ItemWidth常數和水平居中內容? –