国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

IOS數字鍵盤左下角添加完成按鈕的實現方法

2019-10-21 18:44:59
字體:
來源:轉載
供稿:網友

IOS數字鍵盤左下角添加完成按鈕的實現方法

實現代碼:

- (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數字鍵盤左下角添加完成按鈕的實現方法,如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!


注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 垣曲县| 洪江市| 衡阳市| 怀远县| 姚安县| 龙南县| 崇礼县| 老河口市| 武川县| 北票市| 工布江达县| 合阳县| 乐至县| 仁寿县| 丰城市| 阳曲县| 宁蒗| 富裕县| 云林县| 延长县| 鄱阳县| 万源市| 喀喇| 九台市| 淮北市| 平原县| 彭州市| 湟中县| 介休市| 深泽县| 永宁县| 正安县| 鄂托克旗| 绵竹市| 抚松县| 云南省| 麟游县| 房山区| 龙游县| 富宁县| 宜都市|