IOS开发中自定义键盘的切换效果

释放双眼,带上耳机,听听看~!

不管是什么项目的开发都需要程序员编写代码,但是一般的系统键盘是没办法满足程序员的要求,今天技术狗小编为大家带来了IOS开发中自定义键盘的切换效果,一起参考看看吧!

供大家参考,具体内容如下

具体代码如下

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"小飞哥键盘";
self.textField = [[UITextField alloc] initWithFrame:CGRectMake(50, 168, kScreenWidth - 100, 50)];
self.textField.delegate = self;
self.textField.backgroundColor = [UIColor greenColor];
self.textField.placeholder = @"(默认系统键盘)";
[self.view addSubview:self.textField];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hidenKeyBoard)];
[self.view addGestureRecognizer:tap];
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"键盘1",@"键盘2",@"键盘3",@"系统键盘"]];
segment.frame = CGRectMake(0, 100, kScreenWidth, 50);
[segment addTarget:self action:@selector(keyBoardTypeAction:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:segment];
}
- (void)keyBoardTypeAction:(id )sender
{
UISegmentedControl *seg = (UISegmentedControl *)sender;
NSLog(@"intage = %ld", (long)seg.selectedSegmentIndex);
if (seg.selectedSegmentIndex == 0) {
self.xfg_keyboard = [[XFG_KeyBoard alloc] initWithNumber:@1];
self.textField.inputView = self.xfg_keyboard;
self.xfg_keyboard.delegate = self;
[self.textField reloadInputViews];
}
if (seg.selectedSegmentIndex == 1) {
self.xfg_keyboard = [[XFG_KeyBoard alloc] initWithNumber:@2];
self.textField.inputView = self.xfg_keyboard;
self.xfg_keyboard.delegate = self;
[self.textField reloadInputViews];
}
if (seg.selectedSegmentIndex == 2) {
self.xfg_keyboard = [[XFG_KeyBoard alloc] initWithNumber:@3];
self.textField.inputView = self.xfg_keyboard;
self.xfg_keyboard.delegate = self;
[self.textField reloadInputViews];
}
if (seg.selectedSegmentIndex == 3) {
self.textField.inputView = nil;
[self.textField reloadInputViews];
}
}

以上就是技术狗带给大家的IOS开发中自定义键盘的切换效果,开发是值得我们重视的事情,所以一定要来靠谱的平台学习。

人已赞赏
iOS文章

iOS导航栏透明渐变+(源码)

2021-2-5 4:09:52

iOS文章

IOS中如何播放gif动态图

2021-2-5 10:24:54

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索