IOS状态栏背景色修改

2022-05-23  本文已影响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];
    }

上一篇下一篇

猜你喜欢

热点阅读