使用UIImagePickerController获取图库照片后,发现statusBar的颜色从白色变成了黑色,
前 后
显然是UIImagePickerController的navigationbar在作怪,在调用UIImagePickerController的地方,加上如下代码:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
// bug fixes: UIIMagePickerController使用中偷换StatusBar颜色的问题
if ([navigationController isKindOfClass:[UIImagePickerController class]] && ((UIImagePickerController *)navigationController).sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
}
}
效果如下:
修复后
网友评论
pk.navigationBar.tintColor = .white
pk.navigationBar.barStyle = .black