如何在collectionview中将第四张图像显示为半视图...?

时间:2016-04-27 05:36:17

标签: ios uicollectionview

我想在所有版面中将最后一个图像显示为半视图。我怎么能这样做?

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; 
} 

enter image description here

1 个答案:

答案 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)

            }