To run the example project, clone the repo, and run pod install
from the Example directory first.
TemplateScrolls is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'TemplateScrolls'
#import <TemplateScrolls/TTTableView.h>
#import <TemplateScrolls/TTCollectionView.h>
you need extend TTTableViewCell
, TTTableReusableView
or TTCollectionViewCell
, TTCollectionReusableView
#import <TemplateScrolls/TTTableViewCell.h>
@interface TTMessageCell : TTTableViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation TTMessageCell
- (void)makeSubview {
[self.contentView addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(12);
make.top.mas_equalTo(12);
}];
}
- (void)refreshView:(NSString *)data {
self.titleLabel.text = data.title;
}
TTLazyLoadNew(UILabel, titleLabel, {
z.font = [UIFont systemFontOfSize:18 weight:UIFontWeightBold];
})
@end
TTSectionTemplate *section = [TTSectionTemplate new];
section.viewClass = [TTMessageCell class]; // your custom cell
NSArray *dataArray = [@"111", @"222", @"333", ...];
[section.cells addObjectsFromArray:dataArray];
// if you use tableView
TTTableView *tableView = [TTTableView new];
[tableView.sections addObject:section];
// if you use collectionView
TTCollectionView *collectionView = [TTCollectionView new];
[collectionView.sections addObject:section];
A TableView or CollectionView can be rendered immediately.
TemplateScrolls is available under the MIT license. See the LICENSE file for more info.