簡體   English   中英

如何更改imagepickercontroller ios狀態欄的顏色?

[英]how to change color of status bar of 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];
}

使用三個步驟:

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

2:

imagePickerController.delegate = self;

3:

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

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

(要么)

self.view.backgroundColor = [UIColor redColor];
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];
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM