我是ios编程的新手。在这里,我只是想将单元格向右移一点...而且我的顶视图也覆盖了屏幕,我想减小其尺寸以使其与视图正确匹配。如何实现此目的
答案 0 :(得分:1)
使用此行代码。当您寻找它时,它将适合您的单元格。
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
CGFloat spaceBetweenCells = 5;
CGFloat width = (yourMainView.frame.size.width - spaceBetweenCells) / 2;
CGFloat height = (yourMainView.frame.size.height - spaceBetweenCells) / 2.5;
return CGSizeMake(width, width*changeHeight+38 );
}
答案 1 :(得分:0)
尝试
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(8, 8, 0, 0);
}