ios13以后设置导航栏的背景色和标题颜色

// 设置导航栏的标题颜色,字体
    NSDictionary* textAttrs = @{NSForegroundColorAttributeName:
                                    [UIColor whiteColor],
                                NSFontAttributeName:
                                    [UIFont fontWithName:@"Helvetica-Bold"size:17.0],
                                };
//    [self.navigationController.navigationBar setTitleTextAttributes:textAttrs];
    
    
    if (@available(iOS 13.0, *)) {
        
        UINavigationBarAppearance *barApp = [[UINavigationBarAppearance alloc] init];
        [barApp configureWithOpaqueBackground];
        barApp.titleTextAttributes = textAttrs;
        barApp.backgroundColor = [UIColor redColor];
        self.navigationController.navigationBar.standardAppearance = barApp;
        self.navigationController.navigationBar.scrollEdgeAppearance = barApp;
    } else {
        // Fallback on earlier versions
        
        [self.navigationController.navigationBar setTitleTextAttributes:textAttrs];
    }

你可能感兴趣的:(ios13以后设置导航栏的背景色和标题颜色)