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

首頁 > 系統 > iOS > 正文

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

2020-07-26 02:43:07
字體:
來源:轉載
供稿:網友

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 行唐县| 天等县| 石棉县| 旌德县| 鄂伦春自治旗| 庆安县| 农安县| 莱芜市| 永靖县| 丰宁| 东平县| 大方县| 德格县| 阿克| 山阳县| 民勤县| 民县| 运城市| 观塘区| 汝南县| 镇赉县| 河南省| 肇庆市| 泸溪县| 武威市| 台中县| 山阴县| 桐城市| 汝州市| 会昌县| 长乐市| 木里| 波密县| 濮阳市| 临潭县| 白水县| 东乡| 敦化市| 喀喇| 盐津县| 黑山县|