https://github.com/augustrush/uicollectionview-ardynamicheightlayoutcell
Automatically UICollectionViewCell size calculating.
https://github.com/augustrush/uicollectionview-ardynamicheightlayoutcell
height uicollectionview uicollectionviewcell
Last synced: 3 months ago
JSON representation
Automatically UICollectionViewCell size calculating.
- Host: GitHub
- URL: https://github.com/augustrush/uicollectionview-ardynamicheightlayoutcell
- Owner: AugustRush
- License: mit
- Created: 2015-05-19T09:24:26.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-18T05:21:08.000Z (about 9 years ago)
- Last Synced: 2025-03-29T09:12:14.912Z (3 months ago)
- Topics: height, uicollectionview, uicollectionviewcell
- Language: Objective-C
- Size: 27.4 MB
- Stars: 564
- Watchers: 23
- Forks: 86
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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