Navigation bar Change style in * AppDelegate.m

I am using the tr20 framework and trying to change the top naivagu panel from standard to UIStatusBarStyleBlackOpaque.

I tried to use a lot of things in many places, but it does not work: /

I tried in my main * appdelegate.m and then in another "page1.m"

I used below in appdelegate.m

navigator.rootViewController.navigationController.view.backgroundColor = [UIColor redColor];
navigator.rootViewController.navigationController.navigationBar.backgroundColor = [UIColor redColor]; 
navigator.rootViewController.navigationItem.titleView.backgroundColor = [UIColor redColor];
navigator.rootViewController.navigationController.navigationBar.barStyle = UIStatusBarStyleBlackOpaque;
navigator.rootViewController.navigationController.topViewController.navigationController.navigationBar.barStyle = UIStatusBarStyleBlackOpaque;
navigator.rootViewController.navigationController.navigationBar.tintColor = [UIColor blackColor];
navigator.rootViewController.navigationController.navigationBar.translucent = YES;

I used below on page1.m

self.statusBarStyle = UIStatusBarStyleBlackOpaque; // This works! but the below doesnt
self.navigationBarStyle = UIBarStyleBlackOpaque;
self.navigationController.navigationBar.backgroundColor = [UIColor redColor]; 
self.navigationItem.titleView.backgroundColor = [UIColor redColor];
self.navigationController.navigationBar.barStyle = UIStatusBarStyleBlackOpaque;
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.navigationController.navigationBar.translucent = YES;

What am I doing wrong?

thank

EDIT

Also tried the following and still didn't work

self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
self.navigationBarStyle = UIBarStyleBlackOpaque;

and

navigator.rootViewController.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
navigator.rootViewController.navigationController.topViewController.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

/ EDIT2

Debugging did not give me my results, in my .m file, here's the name

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
    self.title = @"MyTitle";
NSLog(self.navigationController.navigationBar.topItem.title);//DIDNT WORK
NSLog(self.navigationItem.title);//Worked
+3
source share
3 answers
self.navigationController.navigationBar.barStyle = UIStatusBarStyleBlackOpaque;

it should be:

self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

// EDIT: for debugging purposes you can log everything

*.navigationBar.topItem.title

, . , .

+4

UIStatusBarStyleBlackOpaque - , , , , ..

,

[[UIApplication sharedApplication] setStatusBarStyle:...]

, , , , , .

-(void)viewDidLoad

0

, ... (, ):

CGFloat version = [[[UIDevice currentDevice] systemVersion] floatValue];
//NSLog(@"version %f", version);
if (version <= 6.1) {
    //NSLog(@"setting navbar style to black");
    [self.navigationController.navigationBar setBarStyle:UIBarStyleBlackOpaque];
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
}
0

Source: https://habr.com/ru/post/1783013/


All Articles