toolbar.barStyle = UIBarStyleBlackTranslucent;
// create a bordered style button with custom title
UIBarButtonItem *facebook = [[[UIBarButtonItem alloc] initWithTitle:@"facebook"
style:UIBarButtonItemStyleBordered target:self
action:@selector(fbAction:)] autorelease];
UIBarButtonItem *twitter = [[[UIBarButtonItem alloc] initWithTitle:@"twitter"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(twAction:)] autorelease];
NSArray *items = [NSArray arrayWithObjects:
facebook,
twitter,
nil];
toolbar.items = items;
// size up the toolbar and set its frame
// please not that it will work only for views without Navigation toolbars.
[toolbar sizeToFit];
CGFloat toolbarHeight = [toolbar frame].size.height;
CGRect mainViewBounds = self.view.bounds;
[toolbar setFrame:CGRectMake(0,0,320,40)];
[self.view addSubview:toolbar];