I am trying to make my collection view cell to cover the height of the screen without going under the navigation bar. I have got the height of the nav bar and use it to make the height of the cell. The problem is that the cell is still taller than it should be and if I scroll down it will go under the nav bar. I needed to be exactly the height of the screen without the nav bar. Code listing below:
override func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let navBarHeight: CGFloat = (self.navigationController?.navigationBar.frame.height)!
let heightOfCell: CGFloat = view.frame.height - navBarHeight
return CGSize(width: view.frame.width, height: heightOfCell)
}