iOS自定義鍵盤切換效果
更新時間:2020年05月26日 15:45:49 作者:緣丶天灬
這篇文章主要為大家詳細介紹了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 = @"(默認系統(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];
}
}
以上就是本文的全部內容,希望對大家學習iOS程序設計有所幫助。
相關文章
iOS AVPlayer切換播放源實現(xiàn)連續(xù)播放和全屏切換的方法
這篇文章主要給大家介紹了關于iOS中AVPlayer切換播放源實現(xiàn)連續(xù)播放和全屏切換的方法,文中給出了詳細的示例代碼供大家參考學習,對大家具有一定的參考學習價值,需要的朋友們下面來一起看看吧。2017-05-05
IOS 實現(xiàn)微信自動搶紅包(非越獄IPhone)
這篇文章主要介紹了IOS 實現(xiàn)微信自動搶紅包(非越獄IPhone)的相關資料,這里對實現(xiàn)自動搶紅包做一個詳細的實現(xiàn)步驟,需要的朋友可以參考下2016-11-11
Objective-C中利用正則去除非數(shù)字字母漢字方法實例
正則表達式對我們日常開發(fā)來說是必不可少的,下面這篇文章主要給大家介紹了關于Objective-C中如何利用正則去除非數(shù)字字母漢字的相關資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考借鑒,下面隨著小編來一起學習學習吧2018-06-06
iOS的XMPPFramework簡單介紹(實現(xiàn)及時通信)
這篇文章主要介紹了iOS的XMPPFramework簡單介紹(實現(xiàn)及時通信),實現(xiàn)了基于XMPP協(xié)議通信的開發(fā),有需要的朋友可以了解一下。2016-11-11

