IOS开发中自定义键盘的切换效果
来源:爱站网时间:2021-02-05编辑:网友分享
不管是什么项目的开发都需要程序员编写代码,但是一般的系统键盘是没办法满足程序员的要求,今天爱站技术频道小编为大家带来了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 Bundle的方法
下一篇:如何实现IOS开发中的远程控制