[翻译] CHTCollectionViewWaterfallLayout
CHTCollectionViewWaterfallLayout

https://github.com/chiahsien/CHTCollectionViewWaterfallLayout
CHTCollectionViewWaterfallLayout is a subclass of UICollectionViewLayout, and it trys to imitate UICollectionViewFlowLayout's usage as much as possible.
This layout is inspired by Pinterest. It also is compatible with PSTCollectionView.
CHTCollectionViewWaterfallLayout是UICollectionViewLayout的子类,尽量模仿它的瀑布流效果,这个布局效果灵感来自于Pinterest。它与PSTCollectionView兼容。

Features 特点
- Easy to use, it trys to imitate UICollectionViewFlowLayout's usage as much as possible.
- Highly customizable.
- Outstanding performance, try 10,000+ items and see the smoothness for yourself.
- Support header and footer views.
- 非常好用,已经把UICollectionViewFlowLayout的使用模拟到了极致。
- 高度可定制性质
- 杰出的效果显示,你可以试试10000+个显示内容,自己体验一下它的流畅度
- 支持header以及footer的views
Prerequisite 前提
- ARC
- Xcode 4.4+, which supports literals syntax.
- iOS 6+, or
- iOS 4.x/5.x, with PSTCollectionView.
How to install 怎么安装
- CocoaPods
Addpod 'CHTCollectionViewWaterfallLayout'to your podfile. - Manual
CopyCHTCollectionViewWaterfallLayout.h/mto your project. 将头文件拷贝到你的工程项目即可
How to Use 怎么使用
Read the demo codes and CHTCollectionViewWaterfallLayout.h header file for more information.
你可以从CHTCollectionViewWaterfallLayout.h头文件中读取到更多的使用细节。
Step 1 - 第1步
Below lists the properties for you to customize the layout. Although they have default values, I strongly recommand you to set up at least the columnCount property to suit your needs. The itemRenderDirection property is an enum which decides the order in which your items will be rendered in subsequent rows. For eg. Left-Right | Right-Left | Shortest column filling up first.
以下列表中得属性是让你来定制layout布局的。虽然他们都有默认值,但我强烈建议你至少设置这个列数columnCount的属性来满足你的需求。itemRenderDirection属性是一个枚举值,用来决定你的rows怎么被你渲染。比如,左-右,右-左,最短的填充。
@property (nonatomic, assign) NSInteger columnCount;
@property (nonatomic, assign) CGFloat minimumColumnSpacing;
@property (nonatomic, assign) CGFloat minimumInteritemSpacing;
@property (nonatomic, assign) CGFloat headerHeight;
@property (nonatomic, assign) CGFloat footerHeight;
@property (nonatomic, assign) UIEdgeInsets sectionInset;
@property (nonatomic, assign) ItemRenderDirection itemRenderDirection;
Step 2 - 第2步
Your collection view's delegate (which often is your view controller) must conforms toCHTCollectionViewDelegateWaterfallLayout protocol and implements the required method, all you need to do is return the original size of the item:
你的collection的代理必须实现这个协议,然后每一个返回相对应的值就行了:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
Step 3 (Optional) - 第3步
If you need to support iOS 4.x/5.x and you have installed PSTCollectionView, then you NEED to modify some codes.
如果你想要兼容iOS 4.x/5.x,那么你就需要安装这个类PSTCollectionView,然后,你需要修改一些源码。
Quoted from PSTCollectionView README file:
If you want to have PSTCollectionView on iOS4.3/5.x and UICollectionView on iOS6, use PSUICollectionView (basically add PS on any UICollectionView* class to get auto-support for older iOS versions) If you always want to use PSTCollectionView, use PSTCollectionView as class names. (replace the UI with PST)
Limitation 限制
- Only vertical scrolling is supported. 只支持竖直滚动
- No decoration view. 没有装饰用view
[翻译] CHTCollectionViewWaterfallLayout的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- button按钮被输入法顶起来,遮盖了input输入框
在做手机端的表单提交的时候,在chrome浏览器调试的时候,忘记输入法会引起布局的问题.在webApp里input输入框,会自动调起输入法,但是输入法会改变浏览器的可视区域的大小.就是会把浏览器可视区 ...
- Android设计原则和设计模式
1. 设计模式的六大基本原则 1.0 总结: 因为抽象灵活性好,适应性广,只要抽象的合理,可以基本保持软件架构的稳定.而软件中易变的细节,我们用从抽象派生的实现类来进行扩展,当软件需要发生变化时,我们 ...
- .Net4.5新特性:正则表达式超时介绍
“Regex” 在数据验证方面最受欢迎.考虑到您可能对“Regex”完全陌生的.请参考我介绍Regex如何运作的视频. But because of the typical parsing logic ...
- ios app真正的相互!!调用
1.需求:A应用打开B.B回跳到A 2.问题: 看到网络上的文档讲的大多数都是app单向跳转的例子,而我们在跳转到第二个app的时候往往需要返回到原来的app,虽然支付宝微信等第三方等应用会有回调 ...
- Java注解(二)
前面了解了注解的基本内容,这次来看一下自定义注解. 自定义注解其实很简单,直接上代码: import java.lang.annotation.Documented; import java.lang ...
- Supervisord安装和配置
http://zhangweide.cn/archive/2013/supervisor-note.html Supervisord supervisord的出现,结束了我这苦恼的问题,它可以帮你守护 ...
- 高并发第十一弹:J.U.C -AQS(AbstractQueuedSynchronizer) 组件:Lock,ReentrantLock,ReentrantReadWriteLock,StampedLock
既然说到J.U.C 的AQS(AbstractQueuedSynchronizer) 不说 Lock 是不可能的.不过实话来说,一般 JKD8 以后我一般都不用Lock了.毕竟sychronize ...
- Win8操作系统下IIS如何配置asp.net的运行环境(win7同样)
一.把鼠标放在电脑屏幕的左下角然后右击,弹出如下图菜单,选择“程序和功能”(快捷键win+X).(win7点击电脑左下角的“开始”,然后点击“控制面板”打开程序与功能界面): 二.进入程序与功能界面后 ...
- BZOJ3238: [Ahoi2013]差异(后缀自动机)
题意 题目链接 Sol 前面的可以直接算 然后原串翻转过来,这时候变成了求任意两个前缀的最长公共后缀,显然这个值应该是\(len[lca]\),求出\(siz\)乱搞一下 #include<bi ...
- Dynamics 365 App for Outlook 与 Dynamics 365 for Outlook(已被弃用)
在最新的版本中Dynamics 365 for Outlook(Outlook 客户端)已被弃用 随 Dynamics CRM 2016(版本 8.0)引入的 Dynamics 365 App for ...