0
minimumInteritemSpacingForSectionAtIndex爲UICollectionViewCell是不正確
上面的圖片顯示4個細胞的中心。正如你所看到的,minimumInteritemSpacingForSectionAtIndex和minimumLineSpacingForSectionAtIndex是不一樣的。我已經設置展位細胞和線路爲1
這裏是我的單元佈局代碼:謝謝
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
//Get device resolution
screenSize = UIScreen.mainScreen().bounds
screenWidth = screenSize.width
screenHeight = screenSize.height
let screenWidth = screenSize.width
let size = CGSize(width: screenWidth/2 , height: 500)
return size
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
return UIEdgeInsetsMake(0, 0, 10, 0);
}
func collectionView(collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat {
return 1.0
}
func collectionView(collectionView: UICollectionView, layout
collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
return 1.0
}
PS:截圖是iPhone 6模擬器。對於iPhone 6加上間距似乎是正確的。