我目前正在研究具有多个导航栏颜色的iphone/ipad应用程序。在应用程序的一部分中,导航栏必须是橙色的,而其他部分则必须是紫色的。在应用程序的开始屏幕上,导航栏是隐藏的。后退按钮不会相应地着色(目标c)
导航栏,后退按钮和栏按钮的颜色根据应用程序的两部分的segue标识符在prepareForSegue中设置。
UIImage *navBackgroundImage = [UIImage imageNamed:@"Navigation-Bar-Orange.png"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
//Change the appearance of back button
UIImage *backButtonImage = [[UIImage imageNamed:@"Back-Orange"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 6)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
//Change the appearance of standard navigation button
UIImage *barButtonImage = [[UIImage imageNamed:@"Standard-Orange"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
[[UIBarButtonItem appearance] setBackgroundImage:barButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Futura-CondensedMedium" size:21.0], UITextAttributeFont, nil]];
当切换到该应用程序(通过SEGUE再次去),导航栏和标准栏按钮将被正确着色的另一部分,但后退按钮会有的前面部分的颜色应用程序。我曾尝试在应用程序中多次设置颜色(例如viewWillAppear和viewDidLoad),但问题仍然存在。
我该如何解决这个问题,并为应用程序的两个部分显示正确的按钮颜色?是否有另一种(更好的)方法来设置不同的导航栏颜色?发生的历史问题
视觉例如:
http://imgur.com/KgxKYOi,kJjC7Iv,wq2mAzf#0
尝试创建UIBarButtonItem * backButton = ...并设置为leftBarButtonItem:[self.navigationItem setLeftBarButtonItem:backButton]; – stosha