0
當我嘗試使用下面的代碼以自定義在UINavigationBar
的項目更改UINavigationBar的項目:遍歷導航層次
CGSize size = [UIImage imageNamed:kGlobalNavigationBarButtonBackOrange].size;
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
[backButton setImage:[UIImage imageNamed:kGlobalNavigationBarButtonBackOrange] forState:UIControlStateNormal];
[backButton setImage:[UIImage imageNamed:kGlobalNavigationBarButtonBackPressedOrange] forState:UIControlStateHighlighted];
[backButton addTarget:self action:@selector(dismissViewController) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Detail"];
[item setLeftBarButtonItem:barButton];
[item setTitleView:self.navigationItem.titleView];
[self.navigationBar pushNavigationItem:item animated:YES];
[self.navigationController pushViewController:vc animated:YES];
然而,當我運行此,導航欄不看任何不同。