我需要像status bar image这样的东西,但我隐藏了状态但仍无法改变颜色。我得到了这个status bar withour color
这就是我在做的事。
-
(void)showGallery
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsEditing = NO;
// picker.navigationBarHidden = YES;
// picker.toolbarHidden = YES;
picker.navigationController.navigationBar.barTintColor=[UIColor orangeColor];
picker.navigationBar.backgroundColor = [UIColor orangeColor];
picker.navigationBar.barStyle=UIBarStyleBlack;
[ picker.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
[self presentViewController:picker animated:YES completion:NULL];
}
答案 0 :(得分:3)
使用三个步骤:
1:将UINavigationControllerDelegate
,UIImagePickerControllerDelegate
添加到@interface yourController ()<>
2:
imagePickerController.delegate = self;
3:
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
答案 1 :(得分:0)
<强> Try This:-
强>
1.创建一个高度为20的视图并更改背景颜色以附加viewcontrollerView(或)更改视图控制器的背景颜色如下
UIView*statusbarview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 20)];
statusbarview.backgroundColor = [UIColor greenColor];
[self.view addSubview:statusbarview];
(OR)
self.view.backgroundColor = [UIColor redColor];
答案 2 :(得分:0)
This solved my problem.
-(void)showGallery
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsEditing = NO;
picker.modalPresentationStyle = UIModalPresentationFullScreen;
picker.navigationBar.translucent = NO;
picker.navigationBar.barTintColor = [UIColor orangeColor];
picker.navigationBar.tintColor = [UIColor whiteColor];
picker.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
[self presentViewController:picker animated:YES completion:nil];
}