我有一個觀點隨着UINavigationBar的如何在UINavigationBar上設置自定義按鈕?
導航欄只允許我在固定位置
與導航欄的兩側固定位置的按鈕..
我想自定義按鈕的位置... 任何主意......會幫我 由於提前
我有一個觀點隨着UINavigationBar的如何在UINavigationBar上設置自定義按鈕?
導航欄只允許我在固定位置
與導航欄的兩側固定位置的按鈕..
我想自定義按鈕的位置... 任何主意......會幫我 由於提前
您不能自上UINavigationItem按鈕的位置,你只能設置rightBarButtonItem和leftBarButtonItem。
如果您真的需要這個,請考慮使用工具欄。
如果您需要後退按鈕,就像導航欄的後退按鈕一樣,請創建一個自定義按鈕並使用圖像。
這是PSD,這將有所幫助。
您可以在UINavigationItem中放置自定義按鈕。這是我如何在右側添加三個按鈕:
// create a toolbar to have three buttons in the right (thanks Mart!)
tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 157, 44.01)];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 1.0, 157.0, 44.1)];
[imgView setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"NavigationBarBackground" ofType:@"png"]]];
[tools addSubview:imgView];
[tools sendSubviewToBack:imgView];
[tools setTintColor:[UIColor colorWithRed:127/255.0 green:184/255.0 blue:72/255.0 alpha:1.0]];
[imgView release];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];
UIBarButtonItem* bi = [[UIBarButtonItem alloc]
initWithTitle:@"Filter" style:UIBarButtonItemStyleBordered target:self action:@selector(showFilter:)];
[buttons addObject:bi];
[bi release];
bi = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"Map.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(showMap:)];
[buttons addObject:bi];
[bi release];
bi = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"Favourite.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(saveSearch:)];
[buttons addObject:bi];
[bi release];
[tools setItems:buttons animated:NO];
[buttons release];
rightBarButton = nil;
rightBarButton = [[UIBarButtonItem alloc] initWithCustomView:tools];
self.navigationItem.rightBarButtonItem = rightBarButton;