我想将UIToolBar
放入UINavigationBar
。UIToolBar背景透明
UIToolbar* tempFontSizeToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(kPaginationToolBarOriginX,kPaginationToolBarOriginY,kPaginationToolBarWidth,kPaginationToolBarHeight)];
tempFontSizeToolBar.backgroundColor = [UIColor clearColor];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] init];
[tempFontSizeToolBar setTranslucent:YES];
UIBarButtonItem *fontSizeBarButtonItem;
fontSizeBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:KpreviousPageIcon] style:UIBarButtonItemStylePlain target:self action:@selector(movePreviousPage:)];
[buttons addObject:fontSizeBarButtonItem];
[fontSizeBarButtonItem release];fontSizeBarButtonItem = nil;
fontSizeBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:KnextpageIcon] style:UIBarButtonItemStylePlain target:self action:@selector(moveNextPage:)];
[buttons addObject:fontSizeBarButtonItem];
[fontSizeBarButtonItem release];fontSizeBarButtonItem = nil;
// stick the buttons in the toolbar
[tempFontSizeToolBar setItems:buttons animated:NO];
[buttons release];buttons = nil;
UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithCustomView:tempFontSizeToolBar];
self.navigationItem.rightBarButtonItem = rightBarItem;
UIToolBar
的背景色是默认的蓝色。 但我需要的工具栏应该是清晰的颜色,以便NavigationBar的背景图像也应该出现在该工具栏中。
请给我建议。
我把工具栏上只有导航栏的顶部。我想要的是工具栏应该是透明的,这样工具栏中的按钮就像它直接放置在导航栏中一样。 – Bharathi 2012-02-22 07:48:38
我已经尝试过这些方法。 setRightBarButtonItems:animated:is only only ios 5 .its crashing when running it on version 4. – Bharathi 2012-02-22 07:55:18
那么你要做的是模仿'setRightBarButtonItems:animated:'在iOS 5中? – QED 2012-02-22 16:08:10