ios - In UICollectionViewCell need to set border effect where it cross to each others (Junction type) -


i implement uicollectionviewcell. need set border effect cell cross each others junction point.

here image, need set border this..

enter image description here

i tried out give cell border in output left & right side border appear not desired output. output this. (wrong output)

enter image description here

so please me..

note: below answer based on discussion between question owner , myself.

you need setup collectionviewflowlayout achieve desired output. try below code:

func collectionview(_ collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: indexpath) -> cgsize {     // values changable according needs.     let layout = collectionview.collectionviewlayout as! uicollectionviewflowlayout     layout.sectioninset = uiedgeinsets.zero     layout.minimuminteritemspacing = 1     layout.minimumlinespacing = 2     return cgsize(width: (self.collectionview.frame.width / 2) - 1 , height:(self.collectionview.frame.height / 3) - 1) } 

update 1: calculating layout includes navigationbar , statusbar.

func collectionview(_ collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: indexpath) -> cgsize {     // values changable according needs.     let layout = collectionview.collectionviewlayout as! uicollectionviewflowlayout     layout.sectioninset = uiedgeinsets.zero     layout.minimuminteritemspacing = 1     layout.minimumlinespacing = 2     return cgsize(width: (self.collectionview.frame.width / 2) - 1 , height:(((self.view.frame.height - ((navigationcontroller?.navigationbar.frame.height)! + uiapplication.shared.statusbarframe.height)) / 3) - 1)) } 

you may need validate collectionview frame in viewdidlayoutsubviews or viewwilllayoutsubviews

 override func viewdidlayoutsubviews() {  collectionview.frame = cgrect(x: 0, y: 0, width: view.frame.width, height: view.frame.height) } 

following link may understand collectionviewflowlayout.

enforce collectionview have 2 rows

uicollectionview remove top padding

adjust cellsize fit screens?

note: in future, post question relevant code , state problem clearly.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -