ios15适配

一、UITableView section增加默认高度
/// Padding above each section header. The default value is `UITableViewAutomaticDimension`.
@property (nonatomic) CGFloat sectionHeaderTopPadding API_AVAILABLE(ios(15.0), tvos(15.0), watchos(8.0));

UITableView又新增了一个新属性:sectionHeaderTopPadding 会给每一个section header 增加一个默认高度,当我们使用UITableViewStylePlain 初始化tableView的时候,就会发现系统默认给section header增高了22像素。
代码更改如下:

if (@available(iOS 15.0, *)) {
    _tableView.sectionHeaderTopPadding = 0;
}
二、navigationBar 设置失效
As of iOS 15, UINavigationBar, UIToolbar, and UITabBar will use their scrollEdgeAppearance when your view controller's associated scroll view is at the appropriate edge (or always if you don't have a UIScrollView in your hierarchy, more on that below).
从 iOS 15 开始,UINavigationBar、UIToolbar 和 UITabBar 将在您的视图控制器的关联滚动视图位于适当的边缘时使用它们的 scrollEdgeAppearance(或者总是如果您的层次结构中没有 UIScrollView,更多内容见下文)。

You must adopt the UIBarAppearance APIs (available since iOS 13, specializations for each bar type) to customize this behavior. UIToolbar and UITabBar add scrollEdgeAppearance properties for this purpose in iOS 15.
您必须采用 UIBarAppearance API(自 iOS 13 起可用,针对每种条形类型进行了专门化)来自定义此行为。 UIToolbar 和 UITabBar 为此在 iOS 15 中添加了 scrollEdgeAppearance 属性。

代码更改如下:

if (@available(iOS 15.0, *)) {
        UINavigationBarAppearance *navigationBarAppearance = [UINavigationBarAppearance new];
        //做一些设置,如:
        //app.backgroundColor = [UIColor whiteColor];
        self.navigationController.navigationBar.scrollEdgeAppearance = navigationBarAppearance;
        self.navigationController.navigationBar.standardAppearance = navigationBarAppearance;
    }

三、tabBarItem失效

设置UITabBarAppearance即可:

UITabBarAppearance * appearance = [UITabBarAppearance new];
appearance.shadowColor = [UIColor clearColor]; //隐藏横线
appearance.stackedLayoutAppearance.normal.titleTextAttributes = @{NSForegroundColorAttributeName:COLOR9B9B9B,NSFontAttributeName:[UIFont systemFontOfSize:12]};
appearance.stackedLayoutAppearance.selected.titleTextAttributes = @{NSForegroundColorAttributeName:COLORFE8505,NSFontAttributeName:[UIFont systemFontOfSize:12]};
self.tabBar.standardAppearance = appearance;

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