Skip to content

m1entus/MZBookshelfCollectionViewLayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MZBookshelfCollectionViewLayout

MZBookshelfCollectionViewLayout is a collection view layout similar to iBooks for UICollectionView.

Interface

extern NSString *const MZBookshelfCollectionViewLayoutDecorationViewKind;

@class MZBookshelfCollectionViewLayout;

@protocol MZBookshelfCollectionViewLayoutDelegate <UICollectionViewDelegateFlowLayout>
@required
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout referenceSizeForDecorationViewForRow:(NSInteger)row inSection:(NSInteger)section;

@optional
- (UIOffset)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout decorationViewAdjustmentForRow:(NSInteger)row inSection:(NSInteger)section;
@end

@interface MZBookshelfCollectionViewLayout : UICollectionViewFlowLayout
@end

Example Usage

- (void)viewDidLoad
{
    [super viewDidLoad];
	
    MZBookshelfCollectionViewLayout *layout = (id)self.collectionView.collectionViewLayout;
    [layout registerNib:[UINib nibWithNibName:@"MZBookShelfDecorationView" bundle:nil] forDecorationViewOfKind:MZBookshelfCollectionViewLayoutDecorationViewKind];
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout referenceSizeForDecorationViewForRow:(NSInteger)row inSection:(NSInteger)section
{
    return CGSizeMake(collectionViewLayout.collectionViewContentSize.width, 30);
}

- (UIOffset)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout decorationViewAdjustmentForRow:(NSInteger)row inSection:(NSInteger)section
{
    return UIOffsetMake(0, 0);
}

Contact

Michał Zaborowski

License

MZBookshelfCollectionViewLayoutDelegate is available under the MIT license. See the LICENSE file for more info.

Bitdeli Badge

About

Bookshelf like iBooks layout for UICollectionView.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages