Tuesday, June 11, 2013

UIToolbar barStyle example in Objective C (iOS).

UIToolbar barStyle

The toolbar style that specifies its appearance.

@property(nonatomic) UIBarStyle barStyle

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

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

[self.navigationController.toolbar setBarStyle:UIBarStyleBlackTranslucent];

Example of [UIToolbar barStyle].
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 barStyle 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 barStyle example article.