IQKeyboardManager 狀態欄(status bar)問題
阿新 • • 發佈:2017-12-20
shared hack inset control gin begin available ear 說明
因為懶,所以具體什麽樣子,參考下面的鏈接
具體的問題情況參考:StatusBar background problem #1158
我解決的思路很簡單,就是在監聽鍵盤消失的時候,去設置 statys bar 的背景顏色。
因為狀態欄並不是消失了,說明不是frame 出了問題,那麽我就修改 它的背景顏色。
具體代碼:
去替換 IQKeyboardManager.m 中的下面的方法
- (void)keyboardDidHide:(NSNotification*)aNotification { CFTimeInterval startTime = CACurrentMediaTime(); [self showLog:[NSString stringWithFormat:@"****** %@ started ******",NSStringFromSelector(_cmd)]]; _topViewBeginRect = CGRectZero; UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"]; if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) { statusBar.backgroundColor= [UIColor whiteColor]; } #ifdef __IPHONE_11_0 if (@available(iOS 11.0, *)) { self.initialAdditionalSafeAreaInsets = UIEdgeInsetsZero; } #endif _kbSize = CGSizeZero; CFTimeInterval elapsedTime = CACurrentMediaTime() - startTime; [self showLog:[NSString stringWithFormat:@"****** %@ ended: %g seconds ******",NSStringFromSelector(_cmd),elapsedTime]]; }
但是由於彈起鍵盤的控制器導航欄的透明度原因會有一些小問題,所以我幹脆就直接不透明。順便把顏色也寫上。這樣就看不出來了。先這樣改吧。
self.navigationController.navigationBar.translucent = NO;
[self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];
IQKeyboardManager 狀態欄(status bar)問題