美文网首页
ios13以后设置导航栏的背景色和标题颜色

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

作者: 笨的很想飞 | 来源:发表于2021-12-23 15:35 被阅读0次
    // 设置导航栏的标题颜色,字体
        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以后设置导航栏的背景色和标题颜色

          本文链接:https://www.haomeiwen.com/subject/mcwhqrtx.html