iOS 15 UI适配

作者: TripleEyeAline | 来源:发表于2021-07-09 18:17 被阅读0次

前言

iOS 15在2021 WWDC会后发布,就勇猛的把水果全家桶都升级了最新系统。两个iOS 15 beta版本过后,系统稳定性整体还不错。也随之发现了几个iOS适配上的bug,在此整理记录下来。后续有发现再继续补充。
Xcode Version 13.0 beta
iOS 15 Developer Beta2

1. UINavigationBar

  • 在iOS 15中,UINavigationBar默认为透明。在滑动时会有模糊效果。如果想要一直就是模糊效果,可以通过改变scrollEdgeAppearance属性来实现。

解决办法:

UINavigationBarAppearance *barApp = [[UINavigationBarAppearance alloc] init];
barApp.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
self.navigationBar.scrollEdgeAppearance = barApp;
  • NavigationBar颜色设置无效
self.navigationController.navigationBar.barTintColor = [[UIColor blueColor] colorWithAlphaComponent:0.5];

往常我们用以上代码来设置导航栏和状态栏背景色,此代码在iOS 15的无效。
apple developer forums

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).

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.

从 iOS 15 开始,UINavigationBar、UIToolbar 和 UITabBar 将在你的VC关联滚动视图位于适当的边缘时使用 scrollEdgeAppearance(或者如果您的试图层级结构中没有 UIScrollView,更多内容见下文)。
您必须使用 UIBarAppearance API 来自定义。UIToolbar 和 UITabBar 为此在 iOS 15 中添加了 scrollEdgeAppearance 属性。

/// Describes the appearance attributes for the tabBar to use when an observable scroll view is scrolled to the bottom. If not set, standardAppearance will be used instead.
@property (nonatomic, readwrite, copy, nullable) UITabBarAppearance *scrollEdgeAppearance UI_APPEARANCE_SELECTOR API_AVAILABLE(ios(15.0));

/// Describes the appearance attributes for the toolbar to use at standard height when an observable scroll view is scrolled to the bottom. If not set, standardAppearance will be used instead.
@property (nonatomic, readwrite, copy, nullable) UIToolbarAppearance *scrollEdgeAppearance UI_APPEARANCE_SELECTOR API_AVAILABLE(ios(15.0));

解决办法:

    if (@available(iOS 15.0, *)) {
        UINavigationBarAppearance *barApp = [UINavigationBarAppearance new];
        barApp.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.5];
        self.navigationController.navigationBar.scrollEdgeAppearance = barApp;
        self.navigationController.navigationBar.standardAppearance = barApp;
    }

2. iOS 15 UITableView sectionHeader下移22像素

iOS 15中 UITableView 新增了一个属性:sectionHeaderTopPadding。此属性会给每一个 section header 增加一个默认高度,当我们使用 UITableViewStylePlain 初始化UITableView 的时候,系统默认给 section header 增高了22像素。

/// 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));

解决办法:

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

相关文章

  • IOS15审核最新详细版

    IOS15适配 导航栏UINavigationBar 从 iOS 15 开始,UINavigationBar、UI...

  • iOS 关于全面屏适配的方案及UI在不同尺寸下适配方案

    iOS 关于全面屏适配的方案及UI在不同尺寸下适配方案 iOS 关于全面屏适配的方案及UI在不同尺寸下适配方案

  • iOS 15 UI适配

    前言 iOS 15在2021 WWDC会后发布,就勇猛的把水果全家桶都升级了最新系统。两个iOS 15 beta版...

  • 2018-11-29

    iOS 关于全面屏适配的方案及UI在不同尺寸下适配方案 - 掘金

  • iPhone iPad 等设备区分 [UI适配]

    在iOS编程时,经常会遇到UI适配,在不同的机型或者iPhone、iPad的UI适配,下面就介绍如何区分iPhon...

  • iPhone X屏幕适配

    iPhone X开发设计屏幕适配。iPhone X(10)屏幕分辨率与适配,iOS开发适配与UI设计问题。 htt...

  • 访问系统通讯录contact iOS9以后的API 附:两个较

    一 . 带UI 二.不带UI 附:适配iOS8的两个类库- AddressBookUI.AddressBook

  • iOS 15 适配

    一年一系统,一年一适配。今天我们来讲一下iOS15适配的相关地方。导航栏适配iOS 15中,导航栏的问题比较明显,...

  • iOS13 适配最新

    iOS13 适配最新 1、iOS的界面UI变化 暗黑模式下 appStatusBar蜜汁变白、Label变白、ce...

  • iOS UI tips

    让超出父视图范围的子视图响应事件,在UIView范围外响应点击 iOS开发之适配iOS11让你的 UI 适配 iO...

网友评论

    本文标题:iOS 15 UI适配

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