1
This commit is contained in:
21
keyBoard/Assets.xcassets/My/mask_top_title.imageset/Contents.json
vendored
Normal file
21
keyBoard/Assets.xcassets/My/mask_top_title.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "mask_top_title.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
keyBoard/Assets.xcassets/My/mask_top_title.imageset/mask_top_title.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/My/mask_top_title.imageset/mask_top_title.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -10,10 +10,12 @@
|
|||||||
@interface KBKeyboardMaskView ()
|
@interface KBKeyboardMaskView ()
|
||||||
@property (nonatomic, strong) UIButton *backButton;
|
@property (nonatomic, strong) UIButton *backButton;
|
||||||
@property (nonatomic, strong) FLAnimatedImageView *gifView;
|
@property (nonatomic, strong) FLAnimatedImageView *gifView;
|
||||||
|
@property (nonatomic, strong) UIImageView *tipLabel; // 顶部提示图
|
||||||
@property (nonatomic, assign) CGFloat keyboardHeight;
|
@property (nonatomic, assign) CGFloat keyboardHeight;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation KBKeyboardMaskView
|
@implementation KBKeyboardMaskView
|
||||||
|
static const CGFloat KGifViewH = (209);
|
||||||
|
|
||||||
- (instancetype)initWithFrame:(CGRect)frame {
|
- (instancetype)initWithFrame:(CGRect)frame {
|
||||||
self = [super initWithFrame:frame];
|
self = [super initWithFrame:frame];
|
||||||
@@ -29,11 +31,8 @@
|
|||||||
|
|
||||||
[_backButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
[_backButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.left.equalTo(self).offset(9);
|
make.left.equalTo(self).offset(9);
|
||||||
if (@available(iOS 11.0, *)) {
|
|
||||||
make.top.equalTo(self.mas_safeAreaLayoutGuideTop).offset(4);
|
make.top.equalTo(self.mas_safeAreaLayoutGuideTop).offset(4);
|
||||||
} else {
|
|
||||||
make.top.equalTo(self).offset(40);
|
|
||||||
}
|
|
||||||
make.width.height.mas_equalTo(40);
|
make.width.height.mas_equalTo(40);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
@@ -41,17 +40,24 @@
|
|||||||
_gifView = [FLAnimatedImageView new];
|
_gifView = [FLAnimatedImageView new];
|
||||||
_gifView.contentMode = UIViewContentModeScaleAspectFit;
|
_gifView.contentMode = UIViewContentModeScaleAspectFit;
|
||||||
_gifView.clipsToBounds = YES;
|
_gifView.clipsToBounds = YES;
|
||||||
|
_gifView.layer.cornerRadius = 30;
|
||||||
|
// _gifView.clipsToBounds = true;
|
||||||
|
_gifView.layer.masksToBounds = true;
|
||||||
[self addSubview:_gifView];
|
[self addSubview:_gifView];
|
||||||
|
|
||||||
// 尺寸固定:宽=屏幕宽,高=300;位置在 layoutSubviews 里根据键盘高度动态计算
|
|
||||||
CGFloat screenW = UIScreen.mainScreen.bounds.size.width;
|
|
||||||
[_gifView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[_gifView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.centerX.equalTo(self);
|
make.centerX.equalTo(self);
|
||||||
make.width.mas_equalTo(KBFit(316));
|
make.width.mas_equalTo(KBFit(316));
|
||||||
make.height.mas_equalTo(KBFit(209));
|
make.height.mas_equalTo(KBFit(KGifViewH));
|
||||||
// 竖直方向不在这里约束,由 layoutSubviews 手动布局
|
// 竖直方向不在这里约束,由 layoutSubviews 手动布局
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
// 顶部提示图
|
||||||
|
_tipLabel = [UIImageView new];
|
||||||
|
_tipLabel.image = [UIImage imageNamed:@"mask_top_title"];
|
||||||
|
_tipLabel.contentMode = UIViewContentModeScaleAspectFit;
|
||||||
|
[self addSubview:_tipLabel];
|
||||||
|
|
||||||
// 整个蒙层点击:激活输入框
|
// 整个蒙层点击:激活输入框
|
||||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapMask:)];
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapMask:)];
|
||||||
[self addGestureRecognizer:tap];
|
[self addGestureRecognizer:tap];
|
||||||
@@ -76,7 +82,7 @@
|
|||||||
// - 无键盘:居中显示;
|
// - 无键盘:居中显示;
|
||||||
// - 有键盘:底部距离键盘上方 20pt,若空间不足则向上顶到顶部预留的 safe 区域。
|
// - 有键盘:底部距离键盘上方 20pt,若空间不足则向上顶到顶部预留的 safe 区域。
|
||||||
CGFloat viewH = CGRectGetHeight(self.bounds);
|
CGFloat viewH = CGRectGetHeight(self.bounds);
|
||||||
CGFloat gifH = 300.0;
|
CGFloat gifH = KBFit(KGifViewH);
|
||||||
CGFloat topMargin = 80.0; // 预留给返回按钮和标题等
|
CGFloat topMargin = 80.0; // 预留给返回按钮和标题等
|
||||||
CGFloat bottomMargin = 20.0;
|
CGFloat bottomMargin = 20.0;
|
||||||
|
|
||||||
@@ -91,9 +97,29 @@
|
|||||||
if (y < topMargin) y = topMargin;
|
if (y < topMargin) y = topMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGRect frame = self.gifView.frame;
|
CGRect gifFrame = self.gifView.frame;
|
||||||
frame.origin.y = y;
|
gifFrame.origin.y = y;
|
||||||
self.gifView.frame = frame;
|
self.gifView.frame = gifFrame;
|
||||||
|
|
||||||
|
// 布局顶部提示图:底部距离 gifView 顶部 20pt,居中显示
|
||||||
|
CGFloat labelMaxWidth = CGRectGetWidth(self.bounds) - 40.0; // 左右各留 20
|
||||||
|
if (labelMaxWidth < 0) { labelMaxWidth = 0; }
|
||||||
|
UIImage *tipImage = self.tipLabel.image;
|
||||||
|
if (!tipImage) { return; }
|
||||||
|
CGFloat imgW = tipImage.size.width;
|
||||||
|
CGFloat imgH = tipImage.size.height;
|
||||||
|
if (imgW <= 0 || imgH <= 0) { return; }
|
||||||
|
CGFloat scale = 1.0;
|
||||||
|
if (imgW > labelMaxWidth && labelMaxWidth > 0) {
|
||||||
|
scale = labelMaxWidth / imgW;
|
||||||
|
}
|
||||||
|
CGFloat labelW = imgW * scale;
|
||||||
|
CGFloat labelH = imgH * scale;
|
||||||
|
|
||||||
|
CGFloat labelX = (CGRectGetWidth(self.bounds) - labelW) * 0.5;
|
||||||
|
CGFloat labelBottom = CGRectGetMinY(self.gifView.frame) - 20.0;
|
||||||
|
CGFloat labelY = labelBottom - labelH;
|
||||||
|
self.tipLabel.frame = CGRectMake(labelX, labelY, labelW, labelH);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)onTapMask:(UITapGestureRecognizer *)gr {
|
- (void)onTapMask:(UITapGestureRecognizer *)gr {
|
||||||
|
|||||||
@@ -62,11 +62,8 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
|
|||||||
make.left.right.equalTo(self.view);
|
make.left.right.equalTo(self.view);
|
||||||
make.height.mas_equalTo(52);
|
make.height.mas_equalTo(52);
|
||||||
// 底部跟随键盘变化
|
// 底部跟随键盘变化
|
||||||
if (@available(iOS 11.0, *)) {
|
|
||||||
self.inputBarBottom = make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
|
self.inputBarBottom = make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
|
||||||
} else {
|
|
||||||
self.inputBarBottom = make.bottom.equalTo(self.view);
|
|
||||||
}
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
|||||||
@@ -71,9 +71,7 @@ static NSString * const kKBVipReviewItemCellId = @"kKBVipReviewItemCellId";
|
|||||||
_collectionView.dataSource = self;
|
_collectionView.dataSource = self;
|
||||||
_collectionView.delegate = self;
|
_collectionView.delegate = self;
|
||||||
[_collectionView registerClass:KBVipReviewItemCell.class forCellWithReuseIdentifier:kKBVipReviewItemCellId];
|
[_collectionView registerClass:KBVipReviewItemCell.class forCellWithReuseIdentifier:kKBVipReviewItemCellId];
|
||||||
if (@available(iOS 11.0, *)) {
|
|
||||||
_collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
_collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return _collectionView;
|
return _collectionView;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,9 +242,7 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
|
|||||||
_collectionView.dataSource = self;
|
_collectionView.dataSource = self;
|
||||||
_collectionView.delegate = self;
|
_collectionView.delegate = self;
|
||||||
_collectionView.alwaysBounceVertical = YES;
|
_collectionView.alwaysBounceVertical = YES;
|
||||||
if (@available(iOS 11.0, *)) {
|
|
||||||
_collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
_collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||||
}
|
|
||||||
[_collectionView registerClass:KBVipPayHeaderView.class forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kKBVipHeaderId];
|
[_collectionView registerClass:KBVipPayHeaderView.class forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kKBVipHeaderId];
|
||||||
[_collectionView registerClass:KBVipSubscribeCell.class forCellWithReuseIdentifier:kKBVipSubscribeCellId];
|
[_collectionView registerClass:KBVipSubscribeCell.class forCellWithReuseIdentifier:kKBVipSubscribeCellId];
|
||||||
[_collectionView registerClass:KBVipReviewListCell.class forCellWithReuseIdentifier:kKBVipReviewListCellId];
|
[_collectionView registerClass:KBVipReviewListCell.class forCellWithReuseIdentifier:kKBVipReviewListCellId];
|
||||||
|
|||||||
@@ -47,9 +47,7 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@available(iOS 11.0, *)) {
|
|
||||||
self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||||
}
|
|
||||||
|
|
||||||
[self beginFirstRefresh];
|
[self beginFirstRefresh];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,10 +100,8 @@ static inline UIWindow *KB_KeyWindow(void) {
|
|||||||
|
|
||||||
// Safe Area
|
// Safe Area
|
||||||
static inline UIEdgeInsets KB_SafeAreaInsets(void) {
|
static inline UIEdgeInsets KB_SafeAreaInsets(void) {
|
||||||
if (@available(iOS 11.0, *)) {
|
|
||||||
UIWindow *w = KB_KeyWindow();
|
UIWindow *w = KB_KeyWindow();
|
||||||
return w ? w.safeAreaInsets : UIEdgeInsetsZero;
|
return w ? w.safeAreaInsets : UIEdgeInsetsZero;
|
||||||
}
|
|
||||||
return UIEdgeInsetsZero;
|
return UIEdgeInsetsZero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user