YJZAlbumCollectionViewLayout
YJZAlbumCollectionViewLayout is a UICollectionViewLayout subclass, used as the layout object of UICollectionView.
Install / Use
/learn @johnny0614/YJZAlbumCollectionViewLayoutREADME
YJZAlbumCollectionViewLayout
YJZAlbumCollectionViewLayout is a UICollectionViewLayout subclass, used as the layout object of UICollectionView.
The idea of YJZAlbumCollectionViewLayout is inspired by RFQuiltLayout. The purpose of it is to allow users to create their desired collection layouts simply and straightforward.
| Default | Custom |
| ------------------------------------------------ |:------------------------------------------:|
|
|
|
How to use
Add the layout as the subclass of your UICollectionViewLayout.

The following code is to create the above custom collection layout
- (void) viewDidLoad {
// ...
YJZAlbumCollectionViewLayout* layout = (id)[self.collectionView collectionViewLayout];
[layout clearLayout];
[layout addLayoutWithRowWidth:320.f rowHeight:100.f layouts:@[[NSValue valueWithCGRect:CGRectMake(0.f, 0.f, 80.f, 100.f)],[NSValue valueWithCGRect:CGRectMake(80.f, 0.f, 80.f, 100.f)],[NSValue valueWithCGRect:CGRectMake(160.f, 0.f, 80.f, 100.f)],[NSValue valueWithCGRect:CGRectMake(240.f, 0.f, 80.f, 100.f)]]];
[layout addLayoutWithRowWidth:320.f rowHeight:100.f layouts:@[[NSValue valueWithCGRect:CGRectMake(0.f, 0.f, 160.f, 100.f)],[NSValue valueWithCGRect:CGRectMake(160.f, 0.f, 80.f, 50.f)],[NSValue valueWithCGRect:CGRectMake(240.f, 0.f, 80.f, 50.f)],[NSValue valueWithCGRect:CGRectMake(160.f, 50.f, 80.f, 50.f)],[NSValue valueWithCGRect:CGRectMake(240.f, 50.f, 80.f, 50.f)]]];
layout.delegate = self;
// ...
}
- (UIEdgeInsets) insetsForItemAtIndexPath:(NSIndexPath *)indexPath {
return UIEdgeInsetsMake(2.f, 2.f, 2.f, 2.f);
}
(Note: all delegate methods are optional)
API
All api methods must be called before prepareLayout is called.
// add a custom row layout
- (void) addLayoutWithRowWidth:(CGFloat) rowWidth rowHeight:(CGFloat) rowHeight layouts:(NSArray*) layouts;
//clear all current layouts
- (void) clearLayout;
Related Skills
node-connect
340.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
340.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.2kCommit, push, and open a PR
