UINavigationBar更改默认样式

  • 改NavigationBar的颜色,UIAppearance里面改TintColor而不是backgroundColor
    [[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];

  • 改NavigationItem的颜色,
    self.navigationController.navigationBar.tintColor = [UIColor greenColor];
    OR
    self.window.tintColor = [UIColor redColor]
    第二种同时修改navigationitem和tabbaritem的选中颜色

  • 改NavigationBar Title的颜色,
    [[UINavigationBar appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]

  • 让backbutton title消失
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];

你可能感兴趣的:(UINavigationBar更改默认样式)