iOS自定義鍵盤切換效果
更新時間:2020年05月26日 15:45:49 作者:緣丶天灬
這篇文章主要為大家詳細(xì)介紹了iOS自定義鍵盤切換效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了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è)計有所幫助。
相關(guān)文章
iOS AVPlayer切換播放源實現(xiàn)連續(xù)播放和全屏切換的方法
這篇文章主要給大家介紹了關(guān)于iOS中AVPlayer切換播放源實現(xiàn)連續(xù)播放和全屏切換的方法,文中給出了詳細(xì)的示例代碼供大家參考學(xué)習(xí),對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。2017-05-05
IOS 實現(xiàn)微信自動搶紅包(非越獄IPhone)
這篇文章主要介紹了IOS 實現(xiàn)微信自動搶紅包(非越獄IPhone)的相關(guān)資料,這里對實現(xiàn)自動搶紅包做一個詳細(xì)的實現(xiàn)步驟,需要的朋友可以參考下2016-11-11
Objective-C中利用正則去除非數(shù)字字母漢字方法實例
正則表達(dá)式對我們?nèi)粘i_發(fā)來說是必不可少的,下面這篇文章主要給大家介紹了關(guān)于Objective-C中如何利用正則去除非數(shù)字字母漢字的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-06-06
iOS的XMPPFramework簡單介紹(實現(xiàn)及時通信)
這篇文章主要介紹了iOS的XMPPFramework簡單介紹(實現(xiàn)及時通信),實現(xiàn)了基于XMPP協(xié)議通信的開發(fā),有需要的朋友可以了解一下。2016-11-11
iOS tableView多輸入框如何獲取數(shù)據(jù)
這篇文章主要給大家介紹了關(guān)于iOS tableView多輸入框如何獲取數(shù)據(jù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04

