swift - Collection View not displaying the whole cells due to vertical scrolling -


i need build custom top menu bar instead of navigation bar. have hidden nav bar , replaced image view in collection view resides. have 4 cells inside width of each 1 being 1/4 of collection view , height being same collection view. problem when run have scroll down view entire cells, because reason escapes me collection view hides part of cells. code , photos below. please me understand why happening? note: have tried set horizontal scrolling messes spacing between cells , last cell not visible, same problem in horizontal mode.

fileprivate func setuptopmenubar() {     view.addsubview(topmenubar)     topmenubar.addsubview(topmenucollectionview)      topmenubar.anchor(view.topanchor, left: view.leftanchor, bottom: nil, right: view.rightanchor, topconstant: 0, leftconstant: 0, bottomconstant: 0, rightconstant: 0, widthconstant: 0, heightconstant: 80)      topmenucollectionview.anchor(nil, left: topmenubar.leftanchor, bottom: topmenubar.bottomanchor, right: topmenubar.rightanchor, topconstant: 0, leftconstant: 30, bottomconstant: 0, rightconstant: 30, widthconstant: 0, heightconstant: 60) }  func collectionview(_ collectionview: uicollectionview, numberofitemsinsection section: int) -> int {     return 4 }  func collectionview(_ collectionview: uicollectionview, cellforitemat indexpath: indexpath) -> uicollectionviewcell {     let cell = collectionview.dequeuereusablecell(withreuseidentifier: cellid, for: indexpath)     return cell }  func collectionview(_ collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitemat indexpath: indexpath) -> cgsize {     return cgsize(width: collectionview.frame.width / 4, height: collectionview.frame.height) }  func collectionview(_ collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, minimuminteritemspacingforsectionat section: int) -> cgfloat {     return 0 // space between cells. }  fileprivate lazy var topmenucollectionview: uicollectionview = {     let layout = uicollectionviewflowlayout()     let cv = uicollectionview(frame: .zero, collectionviewlayout: layout)     cv.backgroundcolor = .clear     cv.datasource = self     cv.delegate = self     cv.register(topmenubarcell.self, forcellwithreuseidentifier: self.cellid)     return cv }() 

the result of run cells not visible

after scrolling down


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -