动态化高度比例
This commit is contained in:
@@ -23,7 +23,8 @@
|
||||
- (void)kb_consumePendingShopSkin;
|
||||
@end
|
||||
|
||||
static CGFloat KEYBOARDHEIGHT = 200 + 50;
|
||||
// 以 375 宽设计稿为基准的键盘总高度(包括顶部工具栏)
|
||||
static const CGFloat kKBKeyboardDesignHeight = 250.0f;
|
||||
|
||||
static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
||||
void *observer,
|
||||
@@ -45,7 +46,6 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
||||
@property (nonatomic, strong) KBFunctionView *functionView; // 功能面板视图(点击工具栏第0个时显示)
|
||||
@property (nonatomic, strong) KBSettingView *settingView; // 设置页
|
||||
@property (nonatomic, strong) UIImageView *bgImageView; // 背景图(在底层)
|
||||
- (void)kb_consumePendingShopSkin;
|
||||
@end
|
||||
|
||||
@implementation KeyboardViewController
|
||||
@@ -87,8 +87,10 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
||||
- (void)setupUI {
|
||||
self.view.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
|
||||
CGFloat keyboardHeight = KEYBOARDHEIGHT; // 250
|
||||
// 按屏幕宽度对设计值做等比缩放,避免在不同机型上键盘整体高度失真导致皮肤被压缩/拉伸
|
||||
CGFloat keyboardHeight = KBFit(kKBKeyboardDesignHeight);
|
||||
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
|
||||
CGFloat outerVerticalInset = KBFit(4.0f);
|
||||
|
||||
NSLayoutConstraint *h = [self.view.heightAnchor constraintEqualToConstant:keyboardHeight];
|
||||
NSLayoutConstraint *w = [self.view.widthAnchor constraintEqualToConstant:screenWidth];
|
||||
@@ -113,15 +115,15 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
||||
[self.view addSubview:self.functionView];
|
||||
[self.functionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.view);
|
||||
make.top.equalTo(self.view).offset(4);
|
||||
make.bottom.equalTo(self.view.mas_bottom).offset(-4);
|
||||
make.top.equalTo(self.view).offset(outerVerticalInset);
|
||||
make.bottom.equalTo(self.view.mas_bottom).offset(-outerVerticalInset);
|
||||
}];
|
||||
|
||||
[self.view addSubview:self.keyBoardMainView];
|
||||
[self.keyBoardMainView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.view);
|
||||
make.top.equalTo(self.view).offset(4);
|
||||
make.bottom.equalTo(self.view.mas_bottom).offset(-4);
|
||||
make.top.equalTo(self.view).offset(outerVerticalInset);
|
||||
make.bottom.equalTo(self.view.mas_bottom).offset(-outerVerticalInset);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user