2016-11-09 78 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]; 
}