UICollectionView-ARDynamicHeightLayoutCell_Bell 1.0.4

UICollectionView-ARDynamicHeightLayoutCell_Bell 1.0.4

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年1月

zjr999Bell 维护。



  • August 和 Bell 创建

分支

从版本 v1.0 的 UICollectionView-ARDynamicHeightLayoutCell 分支出来的

UICollectionView+ARDynamicHeightLayoutCell

  • 一个用于计算自动布局 UICollectionViewCell 大小的简单分类。自动管理 cell 大小缓存,自动失效,效率最高。

演示 Gif

支持

  • Storyboard 中的原型 cell

  • -registerNib:forCellReuseIdentifier

  • -registerClass:forCellReuseIdentifier

使用方法

如果您的 cell 使用自动布局,您只需这样做:

固定宽度

#import "UICollectionView+ARDynamicHeightLayoutCell.h"

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return [collectionView ar_sizeForCellWithIdentifier:@"DynamicHeightCell" fixedWidth:300 configuration:^(id cell) {

       //configuration your cell
        FeedModel *feed = self.feeds[indexPath.row];
        [cell filleCellWithFeed:feed];

    }];
}

固定高度

#import "UICollectionView+ARDynamicHeightLayoutCell.h"

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return [collectionView ar_sizeForCellWithIdentifier:@"DynamicHeightCell" fixedHeight:400 configuration:^(id cell) {
        //configuration your cell
           FeedModel *feed = self.feeds[indexPath.row];
           [cell filleCellWithFeed:feed];
    }
}

动态大小

#import "UICollectionView+ARDynamicHeightLayoutCell.h"

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return [collectionView ar_sizeForCellWithIdentifier:@"DynamicHeightCell" configuration:^(id cell) {
        //configuration your cell
           FeedModel *feed = self.feeds[indexPath.row];
           [cell filleCellWithFeed:feed];
    }
}

安装

pod 'UICollectionView-ARDynamicHeightLayoutCell_Bell'

变更记录

更改日志

许可证

MIT