iOS15适配

前言

中秋过节回来Apple发布了iPhone 13与iOS15正式版的系统推送,开发者又要适配新的系统啦。PS:王守义都说13香
问题1:NavigationBar背景颜色失效,有的变白色,有的变黑色问题

旧版代码

    self.navigationController.navigationBar.barTintColor = UIColorFromRGB(0xFF6507);
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];

新版代码

// 如果是15的系统需要这样设置,非15系统使用老版方法
 if (@available(iOS 15.0, *)) {
          UINavigationBarAppearance *barApp = [UINavigationBarAppearance new];
          barApp.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
          barApp.backgroundColor = UIColorFromRGB(0xFF6507); // 设置为你项目中的颜色
          self.navigationController.navigationBar.scrollEdgeAppearance = barApp; // 可滑动界面配置
          self.navigationController.navigationBar.standardAppearance = barApp; // 普通页面配置
      }
问题2:UITableView新增sectionHeaderTopPadding会使表头新增一段间隙,默认为UITableViewAutomaticDimension
解决办法:
// 此为全局配置,可在AppDelegate中全局统一配置
if (@available(iOS 15.0, *)) {
        [UITableView appearance].sectionHeaderTopPadding = 0;
    }

// 此方法为单一设置某个tableview
  if (@available(iOS 15.0, *)) {
        _tableView.sectionHeaderTopPadding = 0;
    }

开发环境

Xcode版本:Version 13.0
iPhone系统版本:>= 15.0

你可能感兴趣的:(iOS15适配)