测试配置
This commit is contained in:
24
CustomKeyboard/Info.plist
Normal file
24
CustomKeyboard/Info.plist
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict>
|
||||
<key>IsASCIICapable</key>
|
||||
<false/>
|
||||
<key>PrefersRightToLeft</key>
|
||||
<false/>
|
||||
<key>PrimaryLanguage</key>
|
||||
<string>en-US</string>
|
||||
<key>RequestsOpenAccess</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.keyboard-service</string>
|
||||
<key>NSExtensionPrincipalClass</key>
|
||||
<string>KeyboardViewController</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
12
CustomKeyboard/KeyboardViewController.h
Normal file
12
CustomKeyboard/KeyboardViewController.h
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// KeyboardViewController.h
|
||||
// CustomKeyboard
|
||||
//
|
||||
// Created by Mac on 2025/10/27.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface KeyboardViewController : UIInputViewController
|
||||
|
||||
@end
|
||||
79
CustomKeyboard/KeyboardViewController.m
Normal file
79
CustomKeyboard/KeyboardViewController.m
Normal file
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// KeyboardViewController.m
|
||||
// CustomKeyboard
|
||||
//
|
||||
// Created by Mac on 2025/10/27.
|
||||
//
|
||||
|
||||
#import "KeyboardViewController.h"
|
||||
|
||||
static CGFloat KEYBOARDHEIGHT = 256;
|
||||
|
||||
@interface KeyboardViewController ()
|
||||
@property (nonatomic, strong) UIButton *nextKeyboardButton;
|
||||
@end
|
||||
|
||||
@implementation KeyboardViewController
|
||||
|
||||
- (void)updateViewConstraints {
|
||||
[super updateViewConstraints];
|
||||
|
||||
// Add custom view sizing constraints here
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
//
|
||||
// // Perform custom UI setup here
|
||||
// self.nextKeyboardButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
//
|
||||
// [self.nextKeyboardButton setTitle:NSLocalizedString(@"Next Keyboard", @"Title for 'Next Keyboard' button") forState:UIControlStateNormal];
|
||||
// [self.nextKeyboardButton sizeToFit];
|
||||
// self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
//
|
||||
// [self.nextKeyboardButton addTarget:self action:@selector(handleInputModeListFromView:withEvent:) forControlEvents:UIControlEventAllTouchEvents];
|
||||
//
|
||||
// [self.view addSubview:self.nextKeyboardButton];
|
||||
//
|
||||
// [self.nextKeyboardButton.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES;
|
||||
// [self.nextKeyboardButton.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;
|
||||
|
||||
[self setupUI];
|
||||
}
|
||||
|
||||
|
||||
- (void)setupUI {
|
||||
CGFloat toolBarHeight = 40;
|
||||
CGFloat bottom = 5;
|
||||
CGFloat buttonSpace = 8;
|
||||
CGFloat eachButtonHeight = (KEYBOARDHEIGHT - toolBarHeight - 10 - 8 * 3 - bottom) / 4;
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
|
||||
view.backgroundColor = [UIColor redColor];
|
||||
[self.view addSubview:view];
|
||||
}
|
||||
|
||||
|
||||
- (void)viewWillLayoutSubviews
|
||||
{
|
||||
self.nextKeyboardButton.hidden = !self.needsInputModeSwitchKey;
|
||||
[super viewWillLayoutSubviews];
|
||||
}
|
||||
|
||||
- (void)textWillChange:(id<UITextInput>)textInput {
|
||||
// The app is about to change the document's contents. Perform any preparation here.
|
||||
}
|
||||
|
||||
- (void)textDidChange:(id<UITextInput>)textInput {
|
||||
// The app has just changed the document's contents, the document context has been updated.
|
||||
|
||||
UIColor *textColor = nil;
|
||||
if (self.textDocumentProxy.keyboardAppearance == UIKeyboardAppearanceDark) {
|
||||
textColor = [UIColor whiteColor];
|
||||
} else {
|
||||
textColor = [UIColor blackColor];
|
||||
}
|
||||
[self.nextKeyboardButton setTitleColor:textColor forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
@end
|
||||
18
CustomKeyboard/PrefixHeader.pch
Normal file
18
CustomKeyboard/PrefixHeader.pch
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// PrefixHeader.pch
|
||||
// CustomKeyboard
|
||||
//
|
||||
// Created by Mac on 2025/10/27.
|
||||
//
|
||||
|
||||
#ifndef PrefixHeader_pch
|
||||
#define PrefixHeader_pch
|
||||
|
||||
// Include any system framework and library headers here that should be included in all compilation units.
|
||||
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
|
||||
|
||||
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
|
||||
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.width
|
||||
#define imageNamed(s) [UIImage imageNamed:s]
|
||||
|
||||
#endif /* PrefixHeader_pch */
|
||||
16
CustomKeyboard/View/KBToolBar.h
Normal file
16
CustomKeyboard/View/KBToolBar.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// KBToolBar.h
|
||||
// CustomKeyboard
|
||||
//
|
||||
// Created by Mac on 2025/10/27.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface KBToolBar : UIView
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
20
CustomKeyboard/View/KBToolBar.m
Normal file
20
CustomKeyboard/View/KBToolBar.m
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// KBToolBar.m
|
||||
// CustomKeyboard
|
||||
//
|
||||
// Created by Mac on 2025/10/27.
|
||||
//
|
||||
|
||||
#import "KBToolBar.h"
|
||||
|
||||
@implementation KBToolBar
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user