美文网首页
IOS状态栏背景色修改

IOS状态栏背景色修改

作者: 雪域红鹰 | 来源:发表于2022-05-23 14:49 被阅读0次

状态栏使用图片

 NSDictionary *dict = @{
                           NSForegroundColorAttributeName : [UIColor whiteColor],
                           NSFontAttributeName:[UIFont boldSystemFontOfSize:17]
                           };
    if (@available(iOS 15.0, *)) {
        UINavigationBarAppearance *appperance = [[UINavigationBarAppearance alloc]init];
        //添加背景色
        appperance.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"navbar"]];
        appperance.shadowImage = [[UIImage alloc]init];
        appperance.shadowColor = nil;
        //设置字体颜色大小
        [appperance setTitleTextAttributes:dict];
         
        self.navigationController.navigationBar.standardAppearance = appperance;
        self.navigationController.navigationBar.scrollEdgeAppearance = appperance;
        
    }else{
        UINavigationBar *navBar = [UINavigationBar appearance];
        [navBar setBackgroundImage:[UIImage imageNamed:@"navbar"] forBarMetrics:UIBarMetricsDefault];
        [navBar setTitleTextAttributes:dict];
    }

相关文章

网友评论

      本文标题:IOS状态栏背景色修改

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