diff --git a/CustomKeyboard/Model/KBKey.h b/CustomKeyboard/Model/KBKey.h index ba4b7a4..a685dc4 100644 --- a/CustomKeyboard/Model/KBKey.h +++ b/CustomKeyboard/Model/KBKey.h @@ -16,7 +16,7 @@ typedef NS_ENUM(NSInteger, KBKeyType) { KBKeyTypeSpace, // 空格 KBKeyTypeReturn, // 回车/发送 KBKeyTypeGlobe, // 系统地球键 - KBKeyTypeCustom, // 自定义功能占位 + KBKeyTypeCustom, // 自定义功能占位 AI KBKeyTypeSymbolsToggle // 数字面板内的“#+=/123”切换 }; diff --git a/CustomKeyboard/Resource/KBSkinIconMap.strings b/CustomKeyboard/Resource/KBSkinIconMap.strings index bffe465..777b71e 100644 --- a/CustomKeyboard/Resource/KBSkinIconMap.strings +++ b/CustomKeyboard/Resource/KBSkinIconMap.strings @@ -227,6 +227,7 @@ "backspace" = "key_del"; /* Shift(⇧) */ "shift" = "key_up"; +"shift_upper" = "key_up_upper"; /* 字母面板左下角 "123" */ "mode_123" = "key_123"; /* 数字面板左下角 "abc" */ diff --git a/CustomKeyboard/View/KBKeyButton.m b/CustomKeyboard/View/KBKeyButton.m index 8a63db7..64ee914 100644 --- a/CustomKeyboard/View/KBKeyButton.m +++ b/CustomKeyboard/View/KBKeyButton.m @@ -38,7 +38,7 @@ if (!self.iconView) { UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectZero]; // 作为按键的整块皮肤背景,铺满整个按钮区域 - iv.contentMode = UIViewContentModeScaleAspectFit; + iv.contentMode = UIViewContentModeScaleToFill; iv.clipsToBounds = YES; iv.translatesAutoresizingMaskIntoConstraints = NO; [self addSubview:iv]; diff --git a/CustomKeyboard/View/KBKeyboardView.m b/CustomKeyboard/View/KBKeyboardView.m index 783980b..a28662a 100644 --- a/CustomKeyboard/View/KBKeyboardView.m +++ b/CustomKeyboard/View/KBKeyboardView.m @@ -371,12 +371,37 @@ // 避免对基准按钮自身添加 self == self * k 的无效约束 if (b == firstChar) continue; if (b.key.type == KBKeyTypeCharacter) continue; + + // 对 Shift 和 Backspace 强制做 1:1 按钮(宽度 = 高度), + // 主要作用于字母布局第三行左右两侧的两个键,避免被挤压导致图标变形。 + if (b.key.type == KBKeyTypeShift || b.key.type == KBKeyTypeBackspace) { + [b mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.equalTo(b.mas_height); + }]; + continue; + } + CGFloat multiplier = 1.5; - if (b.key.type == KBKeyTypeSpace) multiplier = 4.0; - if (b.key.type == KBKeyTypeReturn) multiplier = 1.8; - if (b.key.type == KBKeyTypeModeChange || b.key.type == KBKeyTypeGlobe || b.key.type == KBKeyTypeShift || b.key.type == KBKeyTypeBackspace) { + + // Space 保持原来的长条比例 + if (b.key.type == KBKeyTypeSpace) { + multiplier = 4.0; + } + // Send 按钮:宽度为基准键的 2.6 倍 + else if (b.key.type == KBKeyTypeReturn) { + multiplier = 2.6; + } + // 删除、123/ABC、#+=、AI:宽度与基准键一致(1 倍,“接近正方形”) + else if (b.key.type == KBKeyTypeModeChange || + b.key.type == KBKeyTypeSymbolsToggle || + b.key.type == KBKeyTypeCustom) { + multiplier = 1.0; + } + // 其它特殊键(如 Globe)保持适度放大 + else if (b.key.type == KBKeyTypeGlobe) { multiplier = 1.5; } + [b mas_makeConstraints:^(MASConstraintMaker *make) { make.width.equalTo(firstChar).multipliedBy(multiplier); }];