ios - How can I create 3 columns using UICollectionView -
i want create 3 columns uicollectionview, here code did: have attached uicollectionviewflowlayout uicollectionview , set itemsize collection view's width divides 3:
self.collectionview.backgroundcolor = [uicolor bluecolor]; uicollectionviewflowlayout *flowlayout = [[uicollectionviewflowlayout alloc] init]; double width = self.collectionview.frame.size.width; width /= 3; [flowlayout setitemsize:cgsizemake(width, 100)]; [flowlayout setscrolldirection:uicollectionviewscrolldirectionhorizontal]; [self.collectionview setcollectionviewlayout:flowlayout];
but when run it, see 1 item per row width of item set correctly. right of item bunch of white spaces.
can please tell me missing?
thank you.
update:
i have tried minimum spacing set. still not work. see 1 column of cells:
self.collectionview.backgroundcolor = [uicolor bluecolor]; uicollectionviewflowlayout *flowlayout = [[uicollectionviewflowlayout alloc] init]; [flowlayout setitemsize:cgsizemake(160, 160)]; [flowlayout setscrolldirection:uicollectionviewscrolldirectionhorizontal]; flowlayout.minimuminteritemspacing = 10.0f; flowlayout.minimumlinespacing = 10.0f; [self.collectionview setcollectionviewlayout:flowlayout];
when adjust spacing values in code, see spacing on screen changes. layout cell in 1 column. instead of 2
while creating uicollectionviewlayout
should specify itemsize
, minimuminteritemspacing
, minimumlinespacing
, optionally scrolling direction using information collection view layout items.
Comments
Post a Comment