Showing posts with label setBarStyle. Show all posts
Showing posts with label setBarStyle. Show all posts

Tuesday, June 11, 2013

UIToolbar setBarStyle example in Objective C (iOS).

UIToolbar setBarStyle

The toolbar style that specifies its appearance.

@property(nonatomic) UIBarStyle barStyle

Discussion of [UIToolbar setBarStyle]
See UIBarStyle for possible values. The default value is UIBarStyleDefault.

UIToolbar setBarStyle example.
In the view controller where you want to set this, add the following to viewDidLoad:

[self.navigationController.toolbar setBarStyle:UIBarStyleBlackTranslucent];

Example of [UIToolbar setBarStyle].
self.bottomToolbar.barStyle = UIBarStyleBlack;
self.bottomToolbar.translucent = YES;
self.bottomToolbar.backgroundColor = [UIColor clearColor];
View opacity set to 1 and these settings did it for me.


UIToolbar setBarStyle example.
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[self.navigationController.toolbar setBarStyle:UIBarStyleBlackOpaque];
UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithTitle:@"toolbar title" style:UIBarButtonItemStylePlain    target:self     action:@selector(onToolbarTapped:)];
NSArray *toolbarItems = [NSArray arrayWithObjects:spaceItem, customItem, spaceItem, nil];

[self setToolbarItems:toolbarItems animated:NO];

End of UIToolbar setBarStyle example article.

Sunday, June 9, 2013

UINavigationBar setBarStyle example in Objective C (iOS).


UINavigationBar setBarStyle

The appearance of the navigation bar.

@property(nonatomic, assign) UIBarStyle barStyle

Discussion of [UINavigationBar setBarStyle]
See UIBarStyle for possible values. The default value is UIBarStyleDefault.

It is permissible to set the value of this property when the navigation bar is being managed by a navigation controller object.

UINavigationBar setBarStyle example.
irstViewController *fvc = [[FirstViewController alloc] init];
UINavigationController *navcon = [[UINavigationController alloc] initWithRootViewController:fvc];
[fvc release];

navcon.navigationBar.barStyle = UIBarStyleBlackTranslucent;

[self.window addSubview:navcon.view];
[self.window makeKeyAndVisible];

return YES;

Example of [UINavigationBar setBarStyle].
The Apple Documentation says to use the following since UIBarStyleBlackTranslucent is deprecated:

navController.navigationBar.barStyle = UIBarStyleBlack;
navController.navigationBar.translucent = YES;
You could try shifting your view back in the correct place or try using the following:

navController.navigationBar.tintColor = [UIColor blackColor];
navController.navigationBar.translucent = YES;

UINavigationBar setBarStyle example.
In RootViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [self.navigationController.navigationBar setBarStyle:UIBarStyleDefault];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"orangeNavigationBar.png"] forBarMetrics:UIBarMetricsDefault];
}
In TranslucentViewController

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
}

End of UINavigationBar setBarStyle example article.