iOS 15 趟坑之旅

前言

本着苹果爸爸系统更新的一贯作风(UI必乱),我开始了iOS15的探索;

基于Xcode Version 13.0 beta (13A5155e) iOS 15 beta2

NavigationBar颜色失效

self.navigationController.navigationBar.barTintColor = [[RSLColorDarMode sharedInstance] colorProviderWithLightColor:[UIColor whiteColor] withDarColor:UIColorFromRGB(0x202020)];

多么正常的代码,多么符合常理的操作,但是在iOS15的页面失效,不起作用;

无奈查找无果,便前去苹果论坛寻找答案,果然功夫不负有心人让我找到了。

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 属性。

so,代码更改如下:

 if (@available(iOS 15.0, *)) {
        UINavigationBarAppearance *navigationBarAppearance = [UINavigationBarAppearance new];
        navigationBarAppearance.backgroundColor = [[RSLColorDarMode sharedInstance] colorProviderWithLightColor:[UIColor whiteColor] withDarColor:UIColorFromRGB(0x202020)];
        self.navigationController.navigationBar.scrollEdgeAppearance = navigationBarAppearance;
        self.navigationController.navigationBar.standardAppearance = navigationBarAppearance;
    }

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像素。

so, 代码更改如下:

if (@available(iOS 15.0, *)) {
    _tableView.sectionHeaderTopPadding = 0;
}

最好改在基类,一次解决所有问题;

目前发现的就是这两个问题,至于苹果爸爸后续会不会修复那鬼知道哦~

后续有新的会继续发出来,也欢迎大佬们留言讨论苹果爸爸的新坑~

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • iOS 11适配源码 Demo地址 安全区域的适配 用Xcode 9 创建storyboard或者xib时,最低版...
    Bytesking阅读 11,602评论 5 24
  • 用到的组件 1、通过CocoaPods安装 2、第三方类库安装 3、第三方服务 友盟社会化分享组件 友盟用户反馈 ...
    SunnyLeong阅读 14,950评论 1 180
  • 表情是什么,我认为表情就是表现出来的情绪。表情可以传达很多信息。高兴了当然就笑了,难过就哭了。两者是相互影响密不可...
    Persistenc_6aea阅读 127,144评论 2 7
  • 16宿命:用概率思维提高你的胜算 以前的我是风险厌恶者,不喜欢去冒险,但是人生放弃了冒险,也就放弃了无数的可能。 ...
    yichen大刀阅读 11,290评论 0 4