Chirag Sondagar
Chirag Sondagar

Reputation: 619

How to set fourth image show as a half view in collectionview...?

I want to display last image show as half view in all layout. How can I do that?

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

Upvotes: 1

Views: 76

Answers (1)

Jasmeet Kaur
Jasmeet Kaur

Reputation: 1568

Implement Collection View Flow Layout 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)

            }

Upvotes: 1

Related Questions