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];
然而,当我运行此,导航栏不看任何不同。