IOS數(shù)字鍵盤左下角添加完成按鈕的實(shí)現(xiàn)方法
IOS數(shù)字鍵盤左下角添加完成按鈕的實(shí)現(xiàn)方法
實(shí)現(xiàn)代碼:
- (void)addDoneButtonToNumPadKeyboard { UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; if (systemVersion < 8.0){ doneButton.frame = CGRectMake(0, 163, 106, 53); }else{ doneButton.frame = CGRectMake(0, SCREEN_SIZE.height-53, 106, 53); } doneButton.tag = NUM_PAD_DONE_BUTTON_TAG; doneButton.adjustsImageWhenHighlighted = NO; [doneButton setTitle:@"完成" forState:UIControlStateNormal]; [doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside]; NSArray *windowArr = [[UIApplication sharedApplication] windows]; if (windowArr != nil && windowArr.count > 1){ UIWindow *needWindow = [windowArr objectAtIndex:1]; UIView *keyboard; for(int i = 0; i < [needWindow.subviews count]; i++) { keyboard = [needWindow.subviews objectAtIndex:i]; NSLog(@"%@", [keyboard description]); if(([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES) || ([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) || ([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] == YES)){ UIView *doneButtonView = [keyboard viewWithTag:NUM_PAD_DONE_BUTTON_TAG]; if (doneButtonView == nil){ [keyboard addSubview:doneButton]; } } } } } -(void)removeDoneButtonFromNumPadKeyboard { UIView *doneButton = nil; NSArray *windowArr = [[UIApplication sharedApplication] windows]; if (windowArr != nil && windowArr.count > 1){ UIWindow *needWindow = [windowArr objectAtIndex:1]; UIView *keyboard; for(int i = 0; i < [needWindow.subviews count]; i++) { keyboard = [needWindow.subviews objectAtIndex:i]; if(([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES) || ([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) || ([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] == YES)){ doneButton = [keyboard viewWithTag:NUM_PAD_DONE_BUTTON_TAG]; if (doneButton != nil){ [doneButton removeFromSuperview]; } } } } }
以上就是IOS數(shù)字鍵盤左下角添加完成按鈕的實(shí)現(xiàn)方法,如有疑問請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
IOS 時(shí)間和時(shí)間戳之間轉(zhuǎn)化示例
我們經(jīng)常從服務(wù)器后臺(tái)拿到時(shí)間戳的時(shí)間,以下代碼可以實(shí)現(xiàn)將時(shí)間戳轉(zhuǎn)為可讀的時(shí)間格式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-01-01iOS簡(jiǎn)單登錄LoginViewController、注冊(cè)RegisterViewController等功能實(shí)現(xiàn)方法
這篇文章主要為大家詳細(xì)介紹了iOS簡(jiǎn)單登錄LoginViewController、注冊(cè)RegisterViewController、UcenterViewController功能實(shí)現(xiàn)方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09iOS對(duì)數(shù)組進(jìn)行排序的實(shí)例代碼
本文通過實(shí)例代碼給大家講解了ios對(duì)數(shù)組進(jìn)行排序的實(shí)例方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的的朋友參考下吧2017-08-08iOS中從網(wǎng)絡(luò)獲取數(shù)據(jù)的幾種方法的比較
IOS中獲取網(wǎng)絡(luò)數(shù)據(jù)一般有三種:1、NSURLCondition(已過時(shí)) 2、NSURLSession 3、三方庫(kù)AFNetWorking。下面通過本文給大家比較這三種方法的區(qū)別對(duì)比2017-11-11iOS NSURLSessionDownloadTask設(shè)置代理文件下載的示例
本篇文章主要介紹了iOS NSURLSessionDownloadTask設(shè)置代理文件下載的示例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-01-01iOS實(shí)現(xiàn)文字轉(zhuǎn)化成彩色文字圖片
這篇文章主要為大家詳細(xì)介紹了iOS文字轉(zhuǎn)化成彩色文字圖片的實(shí)現(xiàn)方法,可以實(shí)現(xiàn)不同字體,漸變的效果,感興趣的小伙伴們可以參考一下2016-03-03