提交
This commit is contained in:
53
Pods/CRBoxInputView/PodCode/Classes/CRBoxFlowLayout.m
generated
Executable file
53
Pods/CRBoxInputView/PodCode/Classes/CRBoxFlowLayout.m
generated
Executable file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// CRBoxFlowLayout.m
|
||||
// CaiShenYe
|
||||
//
|
||||
// Created by Chobits on 2019/1/3.
|
||||
// Copyright © 2019 Chobits. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CRBoxFlowLayout.h"
|
||||
|
||||
@implementation CRBoxFlowLayout
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
[self initPara];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)initPara
|
||||
{
|
||||
self.ifNeedEqualGap = YES;
|
||||
self.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
self.minimumLineSpacing = 0;
|
||||
self.minimumInteritemSpacing = 0;
|
||||
self.sectionInset = UIEdgeInsetsZero;
|
||||
self.itemNum = 1;
|
||||
}
|
||||
|
||||
- (void)prepareLayout
|
||||
{
|
||||
if (_ifNeedEqualGap) {
|
||||
[self autoCalucateLineSpacing];
|
||||
}
|
||||
|
||||
[super prepareLayout];
|
||||
}
|
||||
|
||||
- (void)autoCalucateLineSpacing
|
||||
{
|
||||
if (self.itemNum > 1) {
|
||||
CGFloat width = CGRectGetWidth(self.collectionView.frame);
|
||||
self.minimumLineSpacing = floor(1.0 * (width - self.itemNum * self.itemSize.width) / (self.itemNum - 1));
|
||||
}else{
|
||||
self.minimumLineSpacing = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user