This commit is contained in:
2025-11-27 20:05:39 +08:00
parent 8f16250cbe
commit 3144315de5
8 changed files with 59 additions and 23 deletions

View 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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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;
} }

View File

@@ -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];

View File

@@ -47,9 +47,7 @@
}]; }];
} }
if (@available(iOS 11.0, *)) {
self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[self beginFirstRefresh]; [self beginFirstRefresh];
} }

View File

@@ -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;
} }