我想在所有布局中将最后一个图像显示为半 View 。我该怎么做?
UICollectionViewFlowLayout flowLayout = (UICollectionViewFlowLayout)self.collectionViewFouth.collectionViewLayout;
CGFloat availableWidthForCells = CGRectGetWidth(self.collectionViewFouth.frame) - flowLayout.sectionInset.left - flowLayout.sectionInset.right - flowLayout.minimumInteritemSpacing *2;
cellWidth = availableWidthForCells / 4;
flowLayout.itemSize = CGSizeMake(cellWidth, cellWidth);
- (CGFloat)collectionView:(UICollectionView )collectionView layout:(UICollectionViewLayout)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
return 15;
}
最佳答案
实现 Collection View 流布局委托(delegate)“UICollectionViewDelegateFlowLayout”
func collectionView(collectionView: UICollectionView,layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let width = collectionView.frame.size.width/3.5
let height = 100
return CGSize(width,100)
}
关于ios - 如何在 collectionview 中将第四个图像显示设置为半 View ...?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36881120/