SkillAgentSearch skills...

BSMosaicFlowLayout

Custom layout which allow you to create nice mosaics.

Install / Use

/learn @sssbohdan/BSMosaicFlowLayout
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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

Related Skills

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated4y ago
Forks1

Languages

Objective-C

Security Score

75/100

Audited on Aug 13, 2021

No findings