在我的应用程序的详细视图中,导航控制器的“后退”按钮似乎从某种不敬虔的表现中汲取了色彩的线索。通过一条通往详细视图的路径,它是蓝色的。通过另一个,它是黑色的。在这两种情况下,self.navigationController对象中似乎都不存在后退按钮。
因此,这是一个详细视图:
这是此时导航控制器的快照:
我很确定我知道如何更改此特定元素的颜色,但是我不知道在哪里找到它。有想法吗?
VenueTableViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *show;
if( [self.listType isEqualToString:@"showsByRegion"] )
{
NSString *venueIndex = [[self.allShows allKeys] objectAtIndex:[indexPath indexAtPosition:0]];
int index = [indexPath indexAtPosition:1];
show = [[self.allShows objectForKey:venueIndex] objectAtIndex:index];
} else {
int index = [indexPath indexAtPosition:(indexPath.length - 1)];
show = [self.showsAtVenue objectAtIndex:index];
}
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle:[NSBundle mainBundle]];
detailViewController = [storyboard instantiateViewControllerWithIdentifier:@"InfoViewController"];
detailViewController.showInfo = show;
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
}
InfoViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView = [[self.view subviews] objectAtIndex:1];
[self createInfoViewDictionary];
[self addTopImage];
[self setFrameForTableView];
[self bindLabelsToProperties];
[self.navigationController.navigationBar setTitleTextAttributes:[SHColors sharedInstance].navBarText];
}
如果获得不同的颜色,是因为您是从不同的视图控制器到达的,而这些视图控制器具有不同的tintColor。
然后,您需要使用以下方法设置颜色:
- (void)viewDidLoad
{
....
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
....
}
如果您想让所有导航栏具有相同的颜色,则可以使用UIAppearance代理在AppDelegate中设置它们(已编辑:如Jordan Jordan所说)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句