Skip to content

sssbohdan/BSMosaicFlowLayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BSMozaicFlowLayout

Subclass of UICollectionViewLayout which allow you to create nice Mozaic Layout.

BSMozaicDemo BSMozaicDemo2

Usage

Set FlowLayoutDelegate

BSMozaicLayout *bsMozaicLayout = (BSMozaicLayout *)self.collectionView.collectionViewLayout;
bsMozaicLayout.delegate = self;
bsMozaicLayout.innerCellInset = 3.f;

Implement UICollectionViewDelegate/DataSource and BSMozaicDelegate.

- (CGSize)blockPrimitiveSizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CGSize blockSize = [self getSizeForItemAtIndex:indexPath.row];

    return blockSize;
}

- (NSInteger)countOfColumnInMozaic
{
    return 5;
}

- (CGSize)getSizeForItemAtIndex:(NSUInteger)index
{
    index %= 5;

    if (!index)
        return CGSizeMake(1, 1);
    else if (index == 1)
        return CGSizeMake(1, 2);
    else if (index == 2)
        return CGSizeMake(1, 1);
    else if(index == 3)
        return CGSizeMake(2, 1);
    else if (index == 4)
        return CGSizeMake(1, 1);

    return CGSizeZero;
}

Installation

  1. Import file

    #import "BSMozaicLayout.h"

  2. Add the layout as the subclass of your UICollectionViewLayout. howto

Author

Problems ? Suggestions? Send to me! bbbsavych@gmail.com

About

Custom layout which allow you to create nice mosaics.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published