[翻译] FBLikeLayout

简介:

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

 

目录
相关文章
|
存储 自然语言处理 前端开发
从零写一个Recoil(翻译)
Rewriting Recoil from scratchrecoil是facebook编写的一个库,它之所以诞生是因为人体工程学、context的性能问题和useState。这是一个非常聪明的库,几乎每个人都会找到它的用途——如果你想了解更多,请查看这段解释视频。刚开始我被图论和recoil惊到了,但渐渐的理解后,感觉也没那么特别了。也许我也可以实现一个类似的东西。我自己实现的版本和recoil
245 0
从零写一个Recoil(翻译)
《Wir wilden weisen Frauen》翻译——<连载>
上周去逛图书馆,借了本德语原版的书。今天突然想起来了,就翻开来看。我不知道这本书是否有中文版的,不管有没有吧,我尝试翻译一下以提高自身的德语水平。每天花上一个半小时来翻译,我想应该不能翻译出来几句的。
803 0

热门文章

最新文章