To answer the first question about cell spacing: Extend your ViewController using the UICollectionViewDelegateFlowLayout protocol, and implement the below stubs:
extension ViewController: UICollectionViewDelegateFlowLayout {
func collectionView(
_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAt section: Int
) -> CGFloat { 10.0 } // change value to zero if you want to remove spacing.
func collectionView(
_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumInteritemSpacingForSectionAt section: Int
) -> CGFloat { 10.0 } // change value to zero if you want to remove spacing.
}
The second question:
Your code looks correct, it could be that the string "Park_Cinema_logo" does not match the image name in your bundle?
But if that is not the case here is an extension:
Add this extension in your project.
extension UINavigationBar {
func configureNavigationBarWithImage(name: String) {
let navigationBarIconImageView = UIImageView()
NSLayoutConstraint.activate([
navigationBarIconImageView.widthAnchor.constraint(equalToConstant: frame.size.width),
navigationBarIconImageView.heightAnchor.constraint(equalToConstant: frame.size.height)
])
navigationBarIconImageView.contentMode = .scaleAspectFit
navigationBarIconImageView.image = UIImage(named: name)
topItem?.titleView = navigationBarIconImageView
}
}
And in your ViewController:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?
.navigationBar
.configureNavigationBarWithImage(name: "Park_Cinema_logo")
}