我想將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