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.