我已经更新了我的Xcode到13,后来在我的旧项目导航和选项卡栏颜色改为透明的文字。
我的代码是
[[UINavigationBar appearance] setBarTintColor:[UIColor AppThemeColour]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];我试着添加背景颜色,但是标题和navigationBar的图片不合适。
self.navigationController.navigationBar.backgroundColor = [UIColor bOneAppThemeColor];
[[UINavigationBar appearance] setBarTintColor:[UIColor AppThemeColour]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];我已经研究了下面的链接,但我无法在Objective C中实现它
发布于 2021-09-29 14:05:58
几乎你所做的一切都是错误的(几年来一直都是错误的)。您需要使用UINavigationBarAppearance (和UITabBarAppearance),并将它们应用于栏的standardAppearance和scrollEdgeAppearance。设置外观的背景色,而不是其色调颜色。并且永远不要接触translucent属性。
在这个简单的示例中,我们让所有导航栏都采用您的主题颜色。修改以满足您的需要和愿望:
if (@available(iOS 13.0, *)) {
UINavigationBarAppearance* appear = [UINavigationBarAppearance new];
appear.backgroundColor = [UIColor AppThemeColor];
id proxy = [UINavigationBar appearance];
[proxy setStandardAppearance: appear];
[proxy setScrollEdgeAppearance: appear];
} else {
// Fallback on earlier versions
}https://stackoverflow.com/questions/69377799
复制相似问题