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. 反转ListBox的ListBoxItem(控件级别,不是数据的反转)

    在默认的排序下,当将ListBoxItem往下移动时,ListBoxItem是从其他ListBoxItem的底部移动的如下图:   但当往上移动时,情况则不是如此,     所以需要尝试对ListBo ...

  2. CSS Sprites(CSS精灵) 的优缺点

    CSS Sprites 的优点:     1.减少图片的字节     2.减少了网页的http请求,从而大大的提高了页面的性能     3.解决了网页设计师在图片命名上的困扰,只需对一张集合的图片上命 ...

  3. javascript实例——鼠标特效篇(包含2个实例)

    鼠标是现在电脑的基本配置之一,也是最常用的输入命令的工具之一.本文将将一些与鼠标有关系的特效. 1.跟随鼠标移动的彩色星星 如题,会根据鼠标的移动而移动,并在鼠标周围随机来回移动,让人感觉在放大缩小. ...

  4. Percona-mysql server 5.5升级5.6

    http://blog.csdn.net/lqx0405/article/details/50162557   系统环境:      操作系统:CentOS_6.5(64)            My ...

  5. .Net调用Java端带有WS-Security支持的Web Service【亲测通过】

    做了几年的开发,今天终于鼓起勇气开通了博客园.平时都是找各种大牛,看他们的分享博客的解决BUG.从今天起,我也开始分享我学习之路.还望大家多多支持! 最近收到一个采用Axis2实现的WebServic ...

  6. angularjs 从外部改变controller内的数据

    var appElement = document.querySelector('[ng-controller=seatsCtrl]'); var $scope = angular.element(a ...

  7. 从以前的项目格式迁移到 VS2017 新项目格式

    以前的项目格式使用的是 csproj 的格式,但是 .net core 支持使用 project.json 格式的项目文件,后来还是决定不使用这个格式. VS2017 的项目格式更好读.更简单而且减少 ...

  8. CSS阴影盒子

    box-shadow:inset 横向偏移量  纵向偏移量  模糊范围  扩展范围  阴影颜色: 1.inset :(可选) 内阴影,不设置inset,表示盒子外部显示一个投影.也可写在最后. 2.横 ...

  9. Jsp&Servlet入门级项目全程实录第8讲

    惯例广告一发,对于初学真,真的很有用www.java1234.com,去试试吧! 1.添加dao public int studentAdd(Connection con,Student studen ...

  10. [PHP] 商品类型规格属性后台管理(代码流程备忘)

    实现界面 涉及到四张表,type(商品类型表),type_spec(商品类型规格关联表),attribute(商品属性表),attribute_value(商品属性值表) 新建基控制器BaseCont ...