https://github.com/kittenyang/kytilephotolayout
A UICollectionViewLayout with a really interesting image layout algorithm.
https://github.com/kittenyang/kytilephotolayout
Last synced: 2 months ago
JSON representation
A UICollectionViewLayout with a really interesting image layout algorithm.
- Host: GitHub
- URL: https://github.com/kittenyang/kytilephotolayout
- Owner: KittenYang
- License: mit
- Created: 2015-06-04T03:30:00.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-14T03:22:21.000Z (almost 10 years ago)
- Last Synced: 2025-03-20T13:26:57.787Z (2 months ago)
- Language: Objective-C
- Size: 2.08 MB
- Stars: 227
- Watchers: 8
- Forks: 35
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()


A UICollectionViewLayout with a really interesting image layout algorithm.
一个图片布局算法,实现图片的不规则排列,并且大小不一。具体效果如图:
Algorithm introduce article:
算法介绍文章:
[Blog](http://kittenyang.com/layout-algorithm/)
##垂直滚动:Vertical Scroll
##水平滚动:Horizontal Scroll
##Installation
`pod 'KYTilePhotoLayout', '~> 1.0.0'`
##How to use
It's just two files: `KYTilePhotoLayout.h` && `KYTilePhotoLayout.m`. And it's the subclass of `UICollectionViewLayout`.So you can easily use like a normal `UICollectionViewLayout`. eg:
###*Use code:
```objc
KYTilePhotoLayout *tileLayout = [[KYTilePhotoLayout alloc]init];
tileLayout.ColOfPortrait = 2;
tileLayout.ColOfLandscape = 3;
tileLayout.LayoutDirection = Vertical;
self.collectionView.collectionViewLayout = tileLayout;```
###*Use Interface Builder:
Set the layout's class to **KYTilePhotoLayout** .Then you can set the value visibly:
##How to invoke transition between Portrait and Landscape:
```objc
In you ViewController:#pragma mark -- RotateToReLayout
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
KYTilePhotoLayout *layout = (KYTilePhotoLayout *)self.collectionView.collectionViewLayout;
[layout invalidateLayout];
}```
##License
This project is under MIT License. See LICENSE file for more information.