iOS自定義鍵盤切換效果
更新時(shí)間:2020年05月26日 15:45:49 作者:緣丶天灬
這篇文章主要為大家詳細(xì)介紹了iOS自定義鍵盤切換效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了iOS自定義鍵盤切換的相關(guān)代碼,供大家參考,具體內(nèi)容如下
具體代碼如下
- (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 = @"(默認(rèn)系統(tǒng)鍵盤)"; [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",@"系統(tǒng)鍵盤"]]; 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]; } }
以上就是本文的全部內(nèi)容,希望對大家學(xué)習(xí)iOS程序設(shè)計(jì)有所幫助。
您可能感興趣的文章:
- iOS應(yīng)用開發(fā)中監(jiān)聽鍵盤事件的代碼實(shí)例小結(jié)
- iOS中的UIKeyboard鍵盤視圖使用方法小結(jié)
- iOS實(shí)現(xiàn)輸入框跟隨鍵盤自動上移的實(shí)例代碼
- iOS中鍵盤 KeyBoard 上添加工具欄的方法
- iOS項(xiàng)目開發(fā)鍵盤彈出遮擋輸入框問題解決方案
- h5 ios輸入框和鍵盤的兼容性優(yōu)化指南
- iOS開發(fā)第三方鍵盤處理實(shí)例代碼
- IOS數(shù)字鍵盤左下角添加完成按鈕的實(shí)現(xiàn)方法
- iOS中只讓textField使用鍵盤通知的實(shí)例代碼
- iOS自定義身份證鍵盤
相關(guān)文章
iOS 動畫實(shí)戰(zhàn)之釣魚小游戲?qū)嵗a
最近小編做了一個(gè)釣魚小游戲,平時(shí)沒有做過,所以上手有點(diǎn)急躁,不過,最終還是實(shí)現(xiàn)了,下面小編給大家分享iOS 動畫實(shí)戰(zhàn)之釣魚小游戲的實(shí)現(xiàn)思路,感興趣的朋友一起看看吧2018-02-02Android 在頁面中顯示打包日期的實(shí)現(xiàn)方法
下面小編就為大家分享一篇Android 在頁面中顯示打包日期的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-01-01IOS如何使用CAShapeLayer實(shí)現(xiàn)復(fù)雜的View的遮罩效果
這篇文章主要為大家詳細(xì)介紹了IOS如何使用CAShapeLayer實(shí)現(xiàn)復(fù)雜的View的遮罩效果,感興趣的小伙伴們可以參考一下2016-03-03