【问题标题】:how to change color of status bar of imagepickercontroller ios?如何更改 imagepickercontroller ios 状态栏的颜色?
【发布时间】:2017-03-23 10:48:11
【问题描述】:

我需要像 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];
}

【问题讨论】:

    标签: ios iphone ios7 uiimagepickercontroller ios7-statusbar


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:
      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];
      }
      

      【讨论】:

        【解决方案3】:

        使用三个步骤:

        1:将UINavigationControllerDelegateUIImagePickerControllerDelegate 添加到您的@interface yourController ()<>

        2:

        imagePickerController.delegate = self;
        

        3:

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

        【讨论】:

          猜你喜欢
          • 2016-11-04
          • 2018-08-27
          • 2021-08-03
          • 2016-10-16
          • 2020-01-16
          • 1970-01-01
          • 2021-11-05
          相关资源
          最近更新 更多