Я использую UICollectionView
. in Collection View> Size Inspector> Min Spacing, I изменено на 0
и 1
.Как удалить пространство ячеек в UICollectionView
Я хотел бы удалить любое пространство между любыми ячейками. как я могу это сделать?
как я могу удалить пространство между двумя ячейками без написания кода (белый пробел)?
class FirstPageViewController: UIViewController ,UICollectionViewDataSource, UICollectionViewDelegate
....
let reuseIdentifier = "cellFirstPage"
var items = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48","49","50"]
// MARK: - UICollectionViewDataSource protocol
// tell the collection view how many cells to make
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.items.count
}
// make a cell for each cell index path
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
// get a reference to our storyboard cell
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! ViewHolderFirstMainControllerCollectionViewController
// Use the outlet in our custom class to get a reference to the UILabel in the cell
print(self.items[indexPath.item])
cell.lbl_title.text = self.items[indexPath.item]
cell.backgroundColor = UIColor.cyan // make cell more visible in our example project
return cell
}
// MARK: - UICollectionViewDelegate protocol
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// handle tap events
print("You selected cell #\(indexPath.item)!")
}
func collectionView(collectionView: UICollectionView, layout
collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
return 1.0
}
Если я не могу без использования кода для записи, напишите быстрый код.
http://stackoverflow.com/a/40261279/4601170 –
Проверьте это разместите http://stackoverflow.com/questions/40131349/enforce-collectionview-to-have-only-2-rows/40133928#40133928 и установите все интервалы равными нулю. – Joe