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;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 前言 本着苹果爸爸系统更新的一贯作风(UI必乱),我开始了iOS15的探索; 基于Xcode Version 13...
    e42f53e4b8ea阅读 8,009评论 4 4
  • 1.badgeVaule气泡提示 2.git终端命令方法> pwd查看全部 >cd>ls >之后桌面找到文件夹内容...
    i得深刻方得S阅读 10,275评论 1 9
  • 问题有摘自http://ayjkdev.top/2016/03/18/solve-questions/ 问题排序 ...
    乱尘阅读 6,159评论 0 0
  • 表情是什么,我认为表情就是表现出来的情绪。表情可以传达很多信息。高兴了当然就笑了,难过就哭了。两者是相互影响密不可...
    Persistenc_6aea阅读 127,837评论 2 7
  • 16宿命:用概率思维提高你的胜算 以前的我是风险厌恶者,不喜欢去冒险,但是人生放弃了冒险,也就放弃了无数的可能。 ...
    yichen大刀阅读 11,312评论 0 4

友情链接更多精彩内容