diff --git a/CustomKeyboard/Resource/KBSkinIconMap.strings b/CustomKeyboard/Resource/KBSkinIconMap.strings index 777b71e..2ae0dba 100644 --- a/CustomKeyboard/Resource/KBSkinIconMap.strings +++ b/CustomKeyboard/Resource/KBSkinIconMap.strings @@ -227,6 +227,7 @@ "backspace" = "key_del"; /* Shift(⇧) */ "shift" = "key_up"; +/* Shift(⇧)大写 */ "shift_upper" = "key_up_upper"; /* 字母面板左下角 "123" */ "mode_123" = "key_123"; diff --git a/CustomKeyboard/Resource/fense.zip b/CustomKeyboard/Resource/fense.zip index f35019b..d6800c0 100644 Binary files a/CustomKeyboard/Resource/fense.zip and b/CustomKeyboard/Resource/fense.zip differ diff --git a/CustomKeyboard/View/KBKeyboardView.m b/CustomKeyboard/View/KBKeyboardView.m index a28662a..2cb036b 100644 --- a/CustomKeyboard/View/KBKeyboardView.m +++ b/CustomKeyboard/View/KBKeyboardView.m @@ -226,6 +226,10 @@ title:@"⇧" output:@"" type:KBKeyTypeShift]; + // Shift 键也支持大小写两套皮肤图: + // - shift.caseVariant = Lower 时,使用 KBSkinIconMap 中 "shift" 对应的短名; + // - shift.caseVariant = Upper 时,使用 "shift_upper" 对应的短名。 + shift.caseVariant = self.shiftOn ? KBKeyCaseVariantUpper : KBKeyCaseVariantLower; [row3 addObject:shift]; for (NSString *s in r3chars) { NSString *shown = self.shiftOn ? s : s.lowercaseString; @@ -357,14 +361,35 @@ // 第二遍:以首个字符键为基准,统一设置特殊键宽度倍数 KBKeyButton *firstChar = nil; + BOOL hasCharacterInRow = NO; for (KBKeyButton *b in row.subviews) { - if ([b isKindOfClass:[KBKeyButton class]] && b.key.type == KBKeyTypeCharacter) { firstChar = b; break; } + if (![b isKindOfClass:[KBKeyButton class]]) continue; + if (b.key.type == KBKeyTypeCharacter) { + firstChar = b; + hasCharacterInRow = YES; + break; + } } // 若该行没有字符键(例如底部控制行),则使用行内第一个按钮作为基准宽度 if (!firstChar) { - for (KBKeyButton *b in row.subviews) { if ([b isKindOfClass:[KBKeyButton class]]) { firstChar = b; break; } } + for (KBKeyButton *b in row.subviews) { + if ([b isKindOfClass:[KBKeyButton class]]) { + firstChar = b; + break; + } + } } if (firstChar) { + // 如果该行本身没有字符键(如底部控制行),且基准按钮是 123/ABC/AI/#+= 等, + // 也将其约束为 1:1,避免 123/ABC 不是正方形。 + if (!hasCharacterInRow && + (firstChar.key.type == KBKeyTypeModeChange || + firstChar.key.type == KBKeyTypeSymbolsToggle || + firstChar.key.type == KBKeyTypeCustom)) { + [firstChar mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.equalTo(firstChar.mas_height); + }]; + } for (KBKeyButton *b in row.subviews) { if (![b isKindOfClass:[KBKeyButton class]]) continue; // 当本行没有字符键时,firstChar 可能是一个“特殊键”, @@ -372,30 +397,30 @@ if (b == firstChar) continue; if (b.key.type == KBKeyTypeCharacter) continue; - // 对 Shift 和 Backspace 强制做 1:1 按钮(宽度 = 高度), - // 主要作用于字母布局第三行左右两侧的两个键,避免被挤压导致图标变形。 - if (b.key.type == KBKeyTypeShift || b.key.type == KBKeyTypeBackspace) { + // 一类键强制宽高比 1:1: + // - 第三行:Shift、Backspace + // - 第四行:123/ABC(ModeChange)、#+=(SymbolsToggle)、AI(Custom) + BOOL isBottomModeKey = (b.key.type == KBKeyTypeModeChange) || + (b.key.type == KBKeyTypeSymbolsToggle) || + (b.key.type == KBKeyTypeCustom); + if (b.key.type == KBKeyTypeShift || + b.key.type == KBKeyTypeBackspace || + isBottomModeKey) { [b mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.equalTo(b.mas_height); + make.width.equalTo(b.mas_height); // 宽度 = 高度,做成正方形 }]; continue; } CGFloat multiplier = 1.5; - // Space 保持原来的长条比例 + // Space:根据行宽可压缩,适当缩小宽度(原来是 4.0,略微调低到 3.0) if (b.key.type == KBKeyTypeSpace) { - multiplier = 4.0; + multiplier = 3.0; } - // Send 按钮:宽度为基准键的 2.6 倍 + // Send 按钮:宽度为基准键的 2.4 倍 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; + multiplier = 2.4; } // 其它特殊键(如 Globe)保持适度放大 else if (b.key.type == KBKeyTypeGlobe) { diff --git a/keyBoard.xcodeproj/project.pbxproj b/keyBoard.xcodeproj/project.pbxproj index 2a12a66..7014ab7 100644 --- a/keyBoard.xcodeproj/project.pbxproj +++ b/keyBoard.xcodeproj/project.pbxproj @@ -36,7 +36,7 @@ 0459D1B42EBA284C00F2D189 /* KBSkinCenterVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0459D1B32EBA284C00F2D189 /* KBSkinCenterVC.m */; }; 0459D1B72EBA287900F2D189 /* KBSkinManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0459D1B62EBA287900F2D189 /* KBSkinManager.m */; }; 0459D1B82EBA287900F2D189 /* KBSkinManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0459D1B62EBA287900F2D189 /* KBSkinManager.m */; }; - 0461310F2ECF0FBC00A6FADF /* fense.zip in Resources */ = {isa = PBXBuildFile; fileRef = 0461310E2ECF0FBC00A6FADF /* fense.zip */; }; + 046131112ECF3A6E00A6FADF /* fense.zip in Resources */ = {isa = PBXBuildFile; fileRef = 046131102ECF3A6E00A6FADF /* fense.zip */; }; 0477BD952EBAFF4E0055D639 /* KBURLOpenBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BD932EBAFF4E0055D639 /* KBURLOpenBridge.m */; }; 0477BDF02EBB76E30055D639 /* HomeSheetVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDEF2EBB76E30055D639 /* HomeSheetVC.m */; }; 0477BDF32EBB7B850055D639 /* KBDirectionIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDF22EBB7B850055D639 /* KBDirectionIndicatorView.m */; }; @@ -229,7 +229,7 @@ 0459D1B32EBA284C00F2D189 /* KBSkinCenterVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBSkinCenterVC.m; sourceTree = ""; }; 0459D1B52EBA287900F2D189 /* KBSkinManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBSkinManager.h; sourceTree = ""; }; 0459D1B62EBA287900F2D189 /* KBSkinManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBSkinManager.m; sourceTree = ""; }; - 0461310E2ECF0FBC00A6FADF /* fense.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = fense.zip; sourceTree = ""; }; + 046131102ECF3A6E00A6FADF /* fense.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = fense.zip; sourceTree = ""; }; 0477BD922EBAFF4E0055D639 /* KBURLOpenBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBURLOpenBridge.h; sourceTree = ""; }; 0477BD932EBAFF4E0055D639 /* KBURLOpenBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBURLOpenBridge.m; sourceTree = ""; }; 0477BDEE2EBB76E30055D639 /* HomeSheetVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeSheetVC.h; sourceTree = ""; }; @@ -484,7 +484,7 @@ children = ( 041007D12ECE012000D203BB /* KBSkinIconMap.strings */, 041007D32ECE012500D203BB /* 002.zip */, - 0461310E2ECF0FBC00A6FADF /* fense.zip */, + 046131102ECF3A6E00A6FADF /* fense.zip */, ); path = Resource; sourceTree = ""; @@ -1425,7 +1425,7 @@ buildActionMask = 2147483647; files = ( 04A9FE202EB893F10020DB6D /* Localizable.strings in Resources */, - 0461310F2ECF0FBC00A6FADF /* fense.zip in Resources */, + 046131112ECF3A6E00A6FADF /* fense.zip in Resources */, 041007D42ECE012500D203BB /* 002.zip in Resources */, 041007D22ECE012000D203BB /* KBSkinIconMap.strings in Resources */, 04286A0B2ECD88B400CE730C /* KeyboardAssets.xcassets in Resources */,