SkillAgentSearch skills...

KYTilePhotoLayout

A UICollectionViewLayout with a really interesting image layout algorithm.

Install / Use

/learn @KittenYang/KYTilePhotoLayout
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<p align="left" > <img src="logo.png" alt="KYTilePhotoLayout" title="KYTilePhotoLayout"> </p>

CocoaPods Version License Platform

A UICollectionViewLayout with a really interesting image layout algorithm.

一个图片布局算法,实现图片的不规则排列,并且大小不一。具体效果如图:

Algorithm introduce article:

算法介绍文章:

Blog

##垂直滚动:Vertical Scroll

<img src="layout_l_v.gif" width = "500"> <img src="layout_p_v.gif" width = "300">

##水平滚动:Horizontal Scroll

<img src="layout_l_h.gif" width = "500"> <img src="layout_p_h.gif" width = "300">

##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:


    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:

<img src="ScreenShot_1.png" width = "500"> <img src="ScreenShot_2.png" width = "500">

##How to invoke transition between Portrait and Landscape:

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.

Related Skills

View on GitHub
GitHub Stars227
CategoryDevelopment
Updated2y ago
Forks35

Languages

Objective-C

Security Score

80/100

Audited on Mar 5, 2024

No findings