Remove vertical space between UICollectionViewCell

I have a UICollectionView that has three cells on each row. There is no vertical space between the cells on all iPhones, except iPhone SE.

There is like 1 point vertical space between the second and the last cells on iPhone SE. I do not understand where it comes from. How to get rid of it?


Code Block
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let collection = ColorCollectionView(sectionHeadersPinToVisibleBounds: false)
self.view.addSubview(collection)
collection.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 8).isActive = true
collection.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 8).isActive = true
collection.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -8).isActive = true
collection.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -8).isActive = true
collection.translatesAutoresizingMaskIntoConstraints = false
let colors: [UIColor] = [.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,
.systemGray, .systemGray2, .systemGray3,]
collection.colors = colors
}
}
class ColorCollectionView: UICollectionView {
var colors: [UIColor] = []
var selectedColor: UIColor?
var headerName: String?
override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: frame, collectionViewLayout: layout)
self.backgroundColor = .clear
self.register(ColorCollectionViewCell.self, forCellWithReuseIdentifier:ColorCollectionViewCell.identifier)
self.dataSource = self
self.delegate = self
}
convenience init(sectionHeadersPinToVisibleBounds: Bool) {
let layout = UICollectionViewFlowLayout()
layout.sectionHeadersPinToVisibleBounds = sectionHeadersPinToVisibleBounds
layout.scrollDirection = .vertical
self.init(frame: .zero, collectionViewLayout: layout)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension ColorCollectionView: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: collectionView.frame.width / 3, height: 60)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,
minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return CGFloat.leastNormalMagnitude
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 8
}
}
extension ColorCollectionView: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return colors.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ColorCollectionViewCell.identifier, for: indexPath)
let color = colors[indexPath.row]
cell.backgroundColor = color
return cell
}
}
class ColorCollectionViewCell: UICollectionViewCell {
static let identifier = "ColorCollectionViewCell"
}



Update

View's width: is 375.0
CollectionView's width: 359.0
CollectionVeiwCell's widht: 119.66666666666667

I appreciate any help!