FBLikeLayout

This is an UICollectionView layout inspired by the photo section of facebook. This layout loads squared items with randomic full size items. It works with standard layout delegate methods. No additional custom methods to be implemented.

这是一个UICollectionView的自动布局文件,灵感来自于Facebook的图片区域效果.这个布局文件加载方形的图片,并自动适应大小.它的代理方法与标准的自动布局代理方法相同.你不需要实现额外的方法.

FBLikeLayout

You can use this layout in your project by adding to your podfile:

你可以用CocoaPods来安装,执行以下一句话即可:

pod 'FBLikeLayout'

Usage

Just allocate a new FBLikeLayout, then customize the few properties this layout comes with

只需要创建出FBLikeayout,然后定制少量的几个属性即可:

FBLikeLayout *layout = [FBLikeLayout new];

//in this case we want 3 cells per row, maximum. This is also the default value if you do not customize the layout.singleCellWidth property
CGFLoat cellWidth = (MIN(self.collectionView.bounds.size.width, self.collectionView.bounds.size.height)-self.collectionView.contentInset.left-self.collectionView.contentInset.right-8)/3.0; layout.minimumInteritemSpacing = 4;
layout.singleCellWidth = cellWidth;
layout.maxCellSpace = 3; //for full size cells, this parameter determines the max cell space //if you want the items size to be forced in order to have the minimumInteritemSpacing always respected. Otherwise the interitem spacing will be adapted in order to cover the complete row with cells
layout.forceCellWidthForMinimumInteritemSpacing = YES;
layout.fullImagePercentageOfOccurrency = 25; //this percent value determines how many times randomly the item will be full size. self.collectionView.collectionViewLayout = layout;

Then just implement the UICollectionViewDelegateFlowLayout method:

然后,实现UICollectionViewDelegateFlowLayout就OK啦:

-(CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath

[翻译] FBLikeLayout的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. mysql数据库数据监测

    #!/bin/bash MYSQL="mysql -h10.10.10.10 -P8036 -uusername -ppassword --default-character-set=utf ...

  2. 从入门到不放弃系列之Koa2

    一.Koa2入门 本来是想Express入门的,但是既然都是要学,干嘛不学最新的呢? 其实我想说,我本来只是想学个小程序开发,现在已经陆陆续续开了好多坑了.. 本文参考廖雪峰教程 二.Async 最新 ...

  3. onclick时间加return和不加return的区别

    JAVASCRIPT在事件中调用函数时用return返回值实际上是对window.event.returnvalue进行设置. 而该值决定了当前操作是否继续.当返回的是true时,将继续操作.当返回是 ...

  4. Oracle11g密码过期处理方法

    首先 查询密码有效期:   SELECT * FROM dba_profiles s WHERE s.profile='DEFAULT' AND resource_name='PASSWORD_LIF ...

  5. 转载:SQL按照日、周、月、年统计数据的方法

    转载源:http://www.jb51.net/article/42613.htm SQL按照日.周.月.季度.年统计数据的方法 方式一: --按日 select sum(consume),day([ ...

  6. SQLSERVER查询整个数据库中某个特定值所在的表和字段的方法

    这几天有业务部门需要使用一个SAP B1老系统  中的报表,但是由于此报表没有加时间条件,导致一旦开始查询 就会导致B1系统异常退出.由于报表对应的SQL 是存在数据库中,所以想通过查找到这个报表的S ...

  7. 前端开发实用工具-Bower的使用。

    参看博客:[https://segmentfault.com/a/1190000002971135]

  8. 【转】SQL语句统计每天、每月、每年的数据

    原文:https://www.cnblogs.com/Fooo/p/3435687.html SQL语句统计每天.每月.每年的数据 1.每年select year(ordertime) 年,sum(T ...

  9. HTML5 Form Data 对象的使用

    HTML5 Form Data 对象的使用  MDN: https://developer.mozilla.org/zh-CN/docs/Web/Guide/Using_FormData_Object ...

  10. 关于android R.layout 中找不到已存在的布局文件问题的解决

    今天遇到一个很奇怪的问题,打R.layout.,居然不会提示已经写好的布局文件,自己把xml文件名打下去后,居然提示错误. 开始以为是R文件中没有自动生成关于布局文件对应的整型,看了R文件,其实是有生 ...