因为懒,所以具体什么样子,参考下面的链接
具体的问题情况参考: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]];
本文详细介绍了在iOS应用中,当键盘弹起时导致StatusBar背景颜色异常的问题及解决方案。通过修改IQKeyboardManager.m文件中的键盘隐藏监听方法,调整StatusBar的背景颜色为白色,同时设置导航栏不透明并指定颜色,有效解决了该问题。
问题&spm=1001.2101.3001.5002&articleId=101285125&d=1&t=3&u=a335b27a10d6471fbd0e8c053a0eb738)
260

被折叠的 条评论
为什么被折叠?



