这里没有任何东西可以解决我所遇到的问题(也许OP也有),因此我想我会分享我的答案。而不是隐藏状态栏,我认为这是一个有问题的解决方案(我注意到它有时会使我的应用处于状态栏被隐藏的状态,而不应该隐藏它)。相反,我选择尝试并与它玩得很好UIStatusBarStyles
。
当呈现UIImagePickerController的视图时,我将状态栏样式设置为default,因为默认的背景色是浅灰色。
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}
然后,关闭图像选择器后,将其重新设置为UIStatusBarStyleLightContent
。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//work
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
//work
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
[self dismissViewControllerAnimated:YES completion:NULL];
}