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.