[英]Specify width between cells and margin in UICollectionView
這是代碼
//-----------------------------------------------------------------------
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake((self.view.frame.size.width - 40) / 3 , (self.view.frame.size.width - 40) / 3);
}
//-----------------------------------------------------------------------
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(10, 10, 10, 10);
}
//-----------------------------------------------------------------------
在這里我想要的是需要在每個屏幕上顯示4個單元格,所有屏幕的各邊各有10px
(self.view.frame.size.width-40)/ 3- > 4個單元格
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.