UICollectionView-ARDynamicHeightLayoutCell 1.0.2

UICollectionView-ARDynamicHeightLayoutCell 1.0.2

测试已测试
语言编程语言 Obj-CObjective C
许可证 MIT
发布上次发布2016年3月

August rush 维护。



  • August

UICollectionView+ARDynamicHeightLayoutCell

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

演示 Gif

支持

  • Storyboard 中的原型单元格

  • -registerNib:forCellReuseIdentifier

  • -registerClass:forCellReuseIdentifier

使用方法

如果你的单元格使用自动布局,你只需要这样做

固定宽度

#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', :git => 'https://github.com/AugustRush/UICollectionView-ARDynamicHeightLayoutCell.git'

发布版本

  • v1.0

    为单元格高度添加缓存,提高效率(自动失效)

  • v0.7

    支持 Storyboard 原型单元格

  • v0.6

    修正了高度计算错误并支持动态大小单元格

  • v0.5

    支持计算 UICollectionView Cell 的大小

待办事项

  • 预先计算缓存