当我们使用使用导航栏上的isTranslucent属性使导航栏变得半透明或不透明的旧方法时,视图的safeAreaInset为半透明导航栏和viceVersa返回非0的值。
但是,当使用下面的代码作为pe新的iOS 13 SDK时,不会出现这种行为。
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = UIColor.systemRed
appearance.titleTextAttributes = [.foregroundColor: UIColor.lightText] // With a red background, make the title more readable.
navigationItem.standardAppearance = appearance
navigationItem.scrollEdgeAppearance = appearance
navigationItem.compactAppearance = appearanc对于这段代码,我仍然看到safeAreaInset.top > 0。
请帮助我理解这种行为。以及如何使用新的UINavigationBarAppearance接口获取inset.top为0。
发布于 2021-10-12 09:53:47
回答我自己的问题:使用isTranslusent和外观API帮助我实现了旧的行为。
As appearance.configureWithOpaqueBackground()只会使条形看起来不透明。
https://stackoverflow.com/questions/69446744
复制相似问题