Skip to content

Commit eb26f0a

Browse files
committed
no message
1 parent 075c726 commit eb26f0a

File tree

9 files changed

+32
-13
lines changed

9 files changed

+32
-13
lines changed

Example/FMLayoutKit/Base.lproj/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
88
</dependencies>
99
<scenes>
10-
<!--View Controller-->
10+
<!--Combine View Controller-->
1111
<scene sceneID="wQg-tq-qST">
1212
<objects>
13-
<viewController id="whP-gf-Uak" customClass="FMViewController" sceneMemberID="viewController">
13+
<viewController id="whP-gf-Uak" customClass="FMCombineViewController" sceneMemberID="viewController">
1414
<layoutGuides>
1515
<viewControllerLayoutGuide type="top" id="uEw-UM-LJ8"/>
1616
<viewControllerLayoutGuide type="bottom" id="Mvr-aV-6Um"/>

Example/FMLayoutKit/FMCombineViewController.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ - (void)viewDidLoad {
112112
make.top.mas_equalTo(100);
113113
}];
114114
self.collectionView = view;
115-
[self addSections];
116-
// [self addCrossFixedSections];
115+
// [self addSections];
116+
[self addCrossFixedSections];
117117
// [self addScaleSection];
118-
self.collectionView.enableLongPressDrag = YES;
118+
// self.collectionView.enableLongPressDrag = YES;
119119
// [self.collectionView setConfigureSourceView:^UIView * _Nonnull(UICollectionViewCell * _Nonnull sourceCell) {
120120
// UIView *source = [[UIView alloc] initWithFrame:sourceCell.frame];
121121
// source.backgroundColor = [UIColor purpleColor];
122122
// return source;
123123
// }];
124124

125-
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"刷新" style:UIBarButtonItemStylePlain target:self.collectionView action:@selector(reloadData)];
125+
// self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"刷新" style:UIBarButtonItemStylePlain target:self.collectionView action:@selector(reloadData)];
126126
}
127127

128128
- (void)addSections{
@@ -182,7 +182,9 @@ - (void)addSections{
182182

183183
section.itemDatas = [@[@"1-1", @"1-2", @"1-3"] mutableCopy];
184184
section.cellElement = [FMLayoutElement elementWithViewClass:[FMCollectionCustomCell class]];
185-
185+
[section setDeqCellReturnElement:^FMLayoutElement * _Nonnull(FMLayoutDynamicSection * _Nonnull section, NSInteger index) {
186+
return [section.cellElements lastObject];
187+
}];
186188
[section setFrameBlock:^CGRect(id _Nonnull section, NSInteger item) {
187189
switch (item) {
188190
case 0:
@@ -303,6 +305,7 @@ - (void)addCrossFixedSections{
303305
section.itemDatas = [@[@"1", @"2", @"2", @"3", @"2", @"3", @"2", @"3", @"2", @"3", @"2", @"3"] mutableCopy];
304306

305307
FMLayoutCrossTransformSection *cSection = [FMLayoutCrossTransformSection sectionAutoWithSection:section];
308+
cSection.transformType = FMLayoutCrossTransformScale;
306309
// [cSection setTransformBlock:^(UICollectionViewCell * _Nonnull cell, CGFloat progress) {
307310
// cell.la
308311
// }];

FMLayoutKit/Classes/Cross/FMLayoutCrossTransformSection.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ - (instancetype)init
1414
self = [super init];
1515
if (self) {
1616
[self setConfigureCollectionView:^(UICollectionView * _Nonnull collectionView, FMLayoutCrossSection * _Nonnull hSection) {
17-
collectionView.decelerationRate = 0;
17+
collectionView.decelerationRate = UIScrollViewDecelerationRateFast;
1818
collectionView.alwaysBounceHorizontal = YES;
1919
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
2020
[collectionView layoutIfNeeded];

FMLayoutKit/Classes/Sections/FMLayoutBaseSection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ NS_ASSUME_NONNULL_BEGIN
145145
- (void)registerCells;
146146
- (void)registerCellsWithCollectionView:(UICollectionView *)collectionView;
147147

148+
- (void)reload;
149+
- (void)reloadItem:(NSInteger)item;
148150
@end
149151

150152
NS_ASSUME_NONNULL_END

FMLayoutKit/Classes/Sections/FMLayoutBaseSection.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ - (void)prepareItems{
255255
NSMutableArray *attrs = [NSMutableArray array];
256256
int first = 0;
257257
if (self.handleType == FMLayoutHandleTypeAppend) {
258-
attrs = [self.itemsAttribute mutableCopy];
258+
attrs = [self.itemsAttribute?:@[] mutableCopy];
259259
first = (int)self.handleItemStart;
260260
}
261261
for (int j = first; j < items; j++) {
@@ -404,4 +404,12 @@ - (FMCollectionLayoutAttributes *)getItemAttributesWithIndex:(NSInteger)j{
404404
@throw [NSException exceptionWithName:@"child class must implementation this method" reason:@"FMLayoutBaseSection" userInfo:nil];
405405
}
406406

407+
- (void)reload{
408+
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:self.indexPath.section]];
409+
}
410+
411+
- (void)reloadItem:(NSInteger)item{
412+
[self.collectionView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:item inSection:self.indexPath.section]]];
413+
}
414+
407415
@end

FMLayoutKit/Classes/Sections/FMLayoutDynamicSection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ typedef CGFloat(^FMLayoutItemOtherBlock)(id section, NSInteger item);
2424
///固定单一分组 当固定单一分组时 可以不用手动配置deqCellReturnReuseId
2525
@property(nonatomic, strong)FMLayoutElement *cellElement;
2626
///获取cell的复用FMLayoutElement
27-
@property(nonatomic, copy)FMLayoutElement *(^deqCellReturnElement)(FMLayoutDynamicSection *section, NSInteger index);
27+
@property(nonatomic, copy)FMLayoutElement *(^deqCellReturnElement)(FMLayoutDynamicSection *section, NSInteger item);
2828
///填充数据 仅当autoHeightFixedWidth为Yes时有用
29-
@property(nonatomic, copy)void(^configurationCell)(FMLayoutDynamicSection *section, UICollectionViewCell *cell, NSInteger index);
29+
@property(nonatomic, copy)void(^configurationCell)(FMLayoutDynamicSection *section, UICollectionViewCell *cell, NSInteger item);
3030
///block返回手动计算的高度 优先级比自动的高
3131
@property(nonatomic, copy)FMLayoutItemOtherBlock otherBlock;
3232

FMLayoutKit/Classes/Sections/FMLayoutDynamicSection.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ - (FMCollectionLayoutAttributes *)getItemAttributesWithIndex:(NSInteger)j{
125125
}
126126

127127
- (UICollectionViewCell *)dequeueReusableCellForIndexPath:(NSIndexPath *)indexPath collectionView:(nonnull UICollectionView *)collectionView{
128+
if (!self.deqCellReturnElement) {
129+
@throw [NSException exceptionWithName:@"dynamic section must have to set deqCellReturnElement value" reason:@"FMLayoutDynamicSection" userInfo:nil];
130+
}
128131
return [collectionView dequeueReusableCellWithReuseIdentifier:self.deqCellReturnElement(self, indexPath.item).reuseIdentifier forIndexPath:indexPath];
129132
}
130133

FMLayoutKit/Classes/Sections/FMLayoutFillSection.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ - (void)prepareItems{
3030
NSMutableArray *attrs = [NSMutableArray array];
3131
int first = 0;
3232
if (self.handleType == FMLayoutHandleTypeAppend) {
33-
attrs = [self.itemsAttribute mutableCopy];
33+
attrs = [self.itemsAttribute?:@[] mutableCopy];
3434
first = (int)self.handleItemStart;
3535
}
3636
CGFloat maxHeight = 0;

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ multi.dataSource = self;
209209

210210
```
211211
#### 版本更新
212-
2020-08-21(1.1.6)
212+
2020-08-21(1.1.9)
213+
修复小bug,增加section刷新方法
214+
215+
2020-08-21(1.1.8)
213216
tesla优化修复bug, 填充布局支持间距
214217
215218
2020-08-02(1.1.6)

0 commit comments

Comments
 (0)