尝试将对象设置为navigationBar的子视图。
设置色调颜色
UINavigationController *theNavigationController = [[UINavigationController alloc] initWithRootViewController: aFeedControler];
theNavigationController.navigationBar.tintColor = [UIColor blackColor];在viewControllers中添加segmentedControl作为子视图,如下所示:
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:[UIImage imageNamed:@"segment_check.png"],
[UIImage imageNamed:@"segment_search.png"],
[UIImage imageNamed:@"segment_tools.png"], nil]];
CGRect frame = CGRectMake(0,0, 200,40);
segmentedControl.frame = frame;
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
segmentedControl.selectedSegmentIndex = 1;
self.navigationItem.titleView = segmentedControl;对于按钮,您应该尝试创建UIButtons而不是UIBarButtonsItems,并将它们添加为子视图。如果您创建UIBarButtonsItems并像这样添加它们self.navigationItem.rightBarButtonItem = tempButton;你会得到你看到的效果。
如果你把它们添加为子视图你不应该有你提到的问题..希望它有所帮助。