美文网首页
iOS13以后适配

iOS13以后适配

作者: 心成则玲 | 来源:发表于2022-06-22 11:20 被阅读0次

    1、UITableView
    在appdelegate方法didFinishLaunchingWithOptions添加代码:

    if (@available(iOS 15.0,*))
        {
            [UITableView appearance].sectionHeaderTopPadding = 0;
        }
    

    2、UINavigation
    在BaseVC中添加:

    if (@available(iOS 13.0,*))
        {
            UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
            appearance.backgroundColor = [UIColor whiteColor];
            appearance.shadowColor = [UIColor whiteColor];
            appearance.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor jk_colorWithHexString:@"#333333"],
                                               NSFontAttributeName:[UIFont fontWithName:@"PingFangSC-Medium" size:18]};
            self.navigationController.navigationBar.standardAppearance = appearance;
            self.navigationController.navigationBar.scrollEdgeAppearance = appearance;
        }
        else
        {
            self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor jk_colorWithHexString:@"#333333"],
                                                       NSFontAttributeName:[UIFont fontWithName:@"PingFangSC-Medium" size:18]};
            [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
            self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
            self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
        }
    

    3、UITabBar

    if (@available(iOS 15.0,*))
        {
            UITabBarAppearance *appearance = [[UITabBarAppearance alloc] init];
            appearance.shadowColor = [UIColor clearColor];
            appearance.backgroundColor = [UIColor whiteColor];
            [UITabBar appearance].scrollEdgeAppearance = appearance;
            [UITabBar appearance].standardAppearance = appearance;
        }
    

    相关文章

      网友评论

          本文标题:iOS13以后适配

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