0

我需要像这个状态栏图像这样的东西,但我正在隐藏状态,但我仍然无法更改颜色。我正在使用我们的颜色获取此状态栏

这就是我正在做的事情。

-

(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];
}
4

3 回答 3

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];
}
于 2016-11-24T06:31:46.043 回答
0

Try This:-

1.创建一个高度为 20 点的视图并更改背景颜色以附加视图控制器视图(或)更改视图控制器的背景颜色如下

UIView*statusbarview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 20)];
statusbarview.backgroundColor = [UIColor greenColor];
[self.view addSubview:statusbarview];

(或者)

self.view.backgroundColor = [UIColor redColor];
于 2016-11-17T07:00:20.403 回答
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];
}
于 2016-11-18T16:27:11.797 回答