0
我想UICollectionView的項是在中央,所以我寫了下面的代碼:設置UICollectionView的UIEdgeInsets
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
let collectionViewWidth = collectionView.bounds.width
let collectionViewHeight = collectionView.bounds.height
let numberOfRows = CGFloat(collectionView.numberOfItemsInSection(0))
let leftValue = (collectionViewWidth/2.0) - (numberOfRows * 5) - (numberOfRows * (collectionViewHeight/2.0))
print(leftValue)
return UIEdgeInsets(top: 0, left: leftValue, bottom: 0, right: 0)
}
但現在的問題是,我不能滾動,以左側爲我的左插圖變化,請建議我任何解決方案。