This commit is contained in:
BearXR
2020-06-11 14:09:44 +08:00
parent ceb3687df7
commit ebdeecd5e2
4 changed files with 16 additions and 6 deletions

View File

@@ -301,9 +301,9 @@
[self.view addSubview:_boxInputView];
[_boxInputView mas_makeConstraints:^(MASConstraintMaker *make) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
make.width.mas_equalTo(XX_6(262));
make.left.mas_equalTo(offXStart);
make.right.mas_equalTo(-offXStart);
make.height.mas_equalTo(YY_6(52));
make.centerX.offset(0);
make.top.equalTo(strongSelf.bigLockImageView.mas_bottom).offset(YY_6(18));
}];
@@ -317,6 +317,7 @@
- (CRBoxInputView *)generateBoxInputView_normal
{
CRBoxInputView *_boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];
_boxInputView.mainCollectionView.contentInset = UIEdgeInsetsMake(0, 20, 0, 20);
[_boxInputView loadAndPrepareViewWithBeginEdit:YES];
if (@available(iOS 12.0, *)) {
@@ -335,6 +336,7 @@
cellProperty.cellPlaceholderFont = [UIFont systemFontOfSize:20];
CRBoxInputView *_boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];
_boxInputView.mainCollectionView.contentInset = UIEdgeInsetsMake(0, 20, 0, 20);
_boxInputView.ifNeedCursor = NO;
_boxInputView.placeholderText = @"露可娜娜";
_boxInputView.customCellProperty = cellProperty;
@@ -364,6 +366,7 @@
};
CRBoxInputView *_boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];
_boxInputView.mainCollectionView.contentInset = UIEdgeInsetsMake(0, 10, 0, 10);
_boxInputView.boxFlowLayout.itemSize = CGSizeMake(XX_6(52), XX_6(52));
_boxInputView.customCellProperty = cellProperty;
[_boxInputView loadAndPrepareViewWithBeginEdit:YES];
@@ -409,6 +412,7 @@
};
CRBoxInputView *_boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];
_boxInputView.mainCollectionView.contentInset = UIEdgeInsetsMake(0, 10, 0, 10);
_boxInputView.boxFlowLayout.itemSize = CGSizeMake(XX_6(52), XX_6(52));
_boxInputView.customCellProperty = cellProperty;
[_boxInputView loadAndPrepareViewWithBeginEdit:YES];
@@ -431,6 +435,7 @@
cellProperty.securitySymbol = @"*";//need
CRBoxInputView *_boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];
_boxInputView.mainCollectionView.contentInset = UIEdgeInsetsMake(0, 10, 0, 10);
_boxInputView.ifNeedSecurity = YES;//need
_boxInputView.boxFlowLayout.itemSize = CGSizeMake(XX_6(52), XX_6(52));
_boxInputView.customCellProperty = cellProperty;
@@ -474,6 +479,7 @@
};
CRBoxInputView *_boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];
_boxInputView.mainCollectionView.contentInset = UIEdgeInsetsMake(0, 10, 0, 10);
_boxInputView.ifNeedSecurity = YES;//need
_boxInputView.boxFlowLayout.itemSize = CGSizeMake(XX_6(52), XX_6(52));
_boxInputView.customCellProperty = cellProperty;
@@ -515,6 +521,7 @@
};
CRBoxInputView *_boxInputView = [[CRBoxInputView alloc] initWithCodeLength:4];
_boxInputView.mainCollectionView.contentInset = UIEdgeInsetsMake(0, 10, 0, 10);
_boxInputView.ifNeedSecurity = YES;//need
_boxInputView.boxFlowLayout.itemSize = CGSizeMake(XX_6(52), XX_6(52));
_boxInputView.customCellProperty = cellProperty;

View File

@@ -19,6 +19,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic) NSInteger itemNum;
/** minLineSpacing
* default: 10
*/
@property (assign, nonatomic) NSInteger minLineSpacing;
- (void)autoCalucateLineSpacing;

View File

@@ -25,7 +25,7 @@
{
self.ifNeedEqualGap = YES;
self.scrollDirection = UICollectionViewScrollDirectionHorizontal;
self.minLineSpacing = 5;
self.minLineSpacing = 10;
self.minimumLineSpacing = 0;
self.minimumInteritemSpacing = 0;
self.sectionInset = UIEdgeInsetsZero;
@@ -45,7 +45,7 @@
{
if (self.itemNum > 1) {
CGFloat width = CGRectGetWidth(self.collectionView.frame);
self.minimumLineSpacing = floor(1.0 * (width - self.itemNum * self.itemSize.width) / (self.itemNum - 1));
self.minimumLineSpacing = floor(1.0 * (width - self.itemNum * self.itemSize.width - self.collectionView.contentInset.left - self.collectionView.contentInset.right) / (self.itemNum - 1));
if (self.minimumLineSpacing < self.minLineSpacing) {
self.minimumLineSpacing = self.minLineSpacing;

View File

@@ -518,8 +518,8 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
_mainCollectionView.backgroundColor = [UIColor clearColor];
_mainCollectionView.delegate = self;
_mainCollectionView.dataSource = self;
_mainCollectionView.layer.masksToBounds = NO;
_mainCollectionView.clipsToBounds = NO;
_mainCollectionView.layer.masksToBounds = YES;
_mainCollectionView.clipsToBounds = YES;
[_mainCollectionView registerClass:[CRBoxInputCell class] forCellWithReuseIdentifier:CRBoxInputCellID];
}