CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jan 2015 |
Maintained by ShinichiKanai.
A spreadsheet view that have header/footer
iOS 6.0 or later
TAXSpreadSheet 0.2.0 or later
via CocoaPods
pod 'TAXHeaderSheet'
Import header
#import "TAXHeaderSheet.h"
Instantiate TAXHeaderSheet and register UICollectionViewCell or subclass for cells the same as UICollectionView.
TAXHeaderSheet *headerSheet = [[TAXHeaderSheet alloc] initWithFrame:CGRectMake(0.0. 0.0. 100.0, 100.0)];
[headerSheet registerClass:[UICollectionViewCell class] forCellInAllSectionWithReuseIdentifier:@"Cell"];
Set metrics of the sheet via properties.
headerSheet.numberOfRowsOfBody = 30;
headerSheet.numberOfColumnsOfBody = 20;
headerSheet.numberOfRowsOfHeader = 1;
headerSheet.numberOfRowsOfFooter = 2;
headerSheet.numberOfColumnsOfHeader = 1;
headerSheet.numberOfColumnsOfFooter = 1;
headerSheet.sizeForCell = CGSizeMake(50.0, 20.0);
headerSheet.widthOfHeaderCell = 50.0;
headerSheet.widthOfFooterCell = 50.0;
headerSheet.heightOfHeaderCell = 20.0;
headerSheet.heightOfFooterCell = 20.0;
headerSheet.heightOfHeader = headerSheet.heightOfHeaderCell *
headerSheet.numberOfRowsOfHeader;
headerSheet.heightOfFooter = headerSheet.heightOfFooterCell * headerSheet.numberOfRowsOfFooter;
headerSheet.widthOfHeader = headerSheet.widthOfHeaderCell * headerSheet.numberOfColumnsOfHeader;
headerSheet.widthOfFooter = headerSheet.widthOfFooterCell * headerSheet.numberOfColumnsOfFooter;
or by implementing delegate methods eg. headerSheet:heightAtRow:ofSectionType:
There is priority for cell height/width:
Header > Footer > Body > Property.
Set DataSource and Delegate objects and implement those methods.
- (UICollectionViewCell*)headerSheet:(TAXHeaderSheet *)headerSheet cellAtRow:(NSUInteger)row column:(NSUInteger)column inSectionType:(TAXHeaderSheetSectionType)sectionType
{
TAXLabelCell *cell = [headerSheet dequeueReusableCellInSectionType:sectionType withReuseIdentifier:CellIdentifier forRow:row column:column];
// Customize cell.
return cell;
}
You should return dequeued UICollectionViewCell subclass in headerSheet:cellAtRow:column:inSectionType
You can use custom UICollectionReusableView subclass for separators. You should register class and dequeue view from HeaderSheet. In case of not using view, return nil.
- (UICollectionReusableView *)headerSheet:(TAXHeaderSheet *)headerSheet separatorViewOfSeparatorType:(TAXHeaderSheetSeparatorType)separatorType
{
UICollectionReusableView *view = [headerSheet dequeueReusableSeparatorViewOfSeparatorType:separatorType withReuseIdentifier:@"Separator"];
view.backgroundColor = [UIColor blueColor];
return view;
}
You can use custom UICollectionReusableView subclass for inter-row/column by implementing delegate methods. You should register class and dequeue view from SpreadSheet. In case of not using view, return nil.
- (UICollectionReusableView *)headerSheet:(TAXHeaderSheet *)headerSheet interRowViewInSectionType:(TAXHeaderSheetSectionType)sectionType belowRow:(NSUInteger)row;
{
if (row == 0) {
UICollectionReusableView *view = [spreadSheet dequeueReusableInterRowViewWithIdentifier:@"View" belowRow:row];
return view;
} else {
return nil;
}
}
MIT License