Reputation: 497
Im using three20 framework and trying to change the top naivagation bar from the standard to UIStatusBarStyleBlackOpaque.
I tried using many things in many places but it does not seem to work :/
I tried in my main *appdelegate.m and then in a another "page1.m"
I've used the below in the 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've used the below in the 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?
Thanks
EDIT
Also tried the following and still did not 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, this is how its called
- (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
Upvotes: 3
Views: 9088
Reputation: 342
This may be what your looking for... (make sure you change the tint color):
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];
}
Upvotes: 0
Reputation:
self.navigationController.navigationBar.barStyle = UIStatusBarStyleBlackOpaque;
should be:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
//EDIT: for debugging purposes you can log all
*.navigationBar.topItem.title
and see if it prints out your current title. If not, its the wrong navigation controller.
Upvotes: 4
Reputation: 47104
UIStatusBarStyleBlackOpaque
is a constant to style the status bar, which is the black or grey thing on the top of your screen, showing time, reception, battery charge etc.
You change it using
[[UIApplication sharedApplication] setStatusBarStyle:...]
as for changing a navigation bar, try the things you listed one by one, and make sure to do it not too early, i.e. not before the view controller has been loaded and initialized.
A good place for these things is in your view controllers -(void)viewDidLoad
Upvotes: 0