UICollectionView-ARDynamicHeightLayoutCell

Automatically UICollectionViewCell size calculating.

Github星跟踪图

UICollectionView+ARDynamicHeightLayoutCell

  • An simple category for caculating autolayout UICollectionViewCell size. Automatic manage cell's size cache, automatic invalidate, most improve efficiency.

Demo gif

Support

  • A prototype cell in storyboard

  • -registerNib:forCellReuseIdentifier:

  • -registerClass:forCellReuseIdentifier:

Usage

if your cell use autolayout , all you need just to do like this:

Fixed width

#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];

    }];
}

Fixed height

#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];
	}
}

Dynamic size

#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];
	}
}

Install

pod 'UICollectionView-ARDynamicHeightLayoutCell', :git => 'https://github.com/AugustRush/UICollectionView-ARDynamicHeightLayoutCell.git'

Release Versions

  • v1.0

    add cache for cell size height, improve efficiency(automatic invalidate)

  • v0.7

    add Support for StoryBoard prototype cell

  • v0.6

    fixed Height caculated bug and support Dynamic size cell

  • v0.5

    support to caculate size for UICollectionView Cell

ToDo

  • pre caculate cache

主要指标

概览
名称与所有者AugustRush/UICollectionView-ARDynamicHeightLayoutCell
主编程语言Objective-C
编程语言Objective-C (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2015-05-19 09:24:26
推送于2016-06-18 05:21:08
最后一次提交2016-06-18 13:20:42
发布数8
最新版本名称1.0.3 (发布于 2016-06-18 13:20:55)
第一版名称0.5 (发布于 2015-05-19 18:14:27)
用户参与
星数563
关注者数23
派生数86
提交数47
已启用问题?
问题数14
打开的问题数5
拉请求数2
打开的拉请求数0
关闭的拉请求数2
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?