2016-11-09 54 views
0

我需要这样的status bar image但我的隐藏状态,但我仍然无法改变颜色。我得到这status bar withour color如何更改imagepickercontroller ios状态栏的颜色?

这就是我在做什么。

-

(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

Try This:-

1,创建具有高度20点查看和更改背景颜色附加viewcontrollerView(OR)更改视图控制器的背景颜色跟随像

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]; 
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]; 
} 
2

使用三个步骤:

1:添加UINavigationControllerDelegateUIImagePickerControllerDelegate@interface yourController()<>

2:

imagePickerController.delegate = self; 

3:

-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated 
{ 
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 
}