ios - UICollectionView: remove margin between cells -
i've collection view , display grid (2columns x n rows) vertical scrolling.
so implement uicollectionviewdelegateflowlayout methods:
func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: nsindexpath) -> cgsize { let collectionviewwidth: cgfloat = collectionview.frame.size.width let cellsize: cgfloat = collectionviewwidth / 2.0 return cgsizemake(cellsize, cellsize); } func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, insetforsectionatindex section: int) -> uiedgeinsets { return uiedgeinsetsmake(0.0, 0.0, 0.0, 0.0) } func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, minimumlinespacingforsectionatindex section: int) -> cgfloat { return 0.0 } func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, minimuminteritemspacingforsectionatindex section: int) -> cgfloat { return 0.0 }
despite this, cells in collection view still separated white space.. i'm wrong?
per method names, giving minimum values, not absolute or maximum ones.
if want cells layouted without spaces, must give them width equal width of screen divided number of cells per row want display.
for example, on 320 pixels wide screen, fit 4 80x80 cells without empty spaces. if give them width of 60 pixels instead, end 20 pixels of empty space given equally between each cells.
Comments
Post a Comment