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];
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容