我想在所有版面中将最后一个图像显示为半视图。我怎么能这样做?
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;
}
答案 0 :(得分:1)
实施集合视图流程布局委托" 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)
}