首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么不透明和透明的UINavigationBarAppearance的view.safeAreaInset是一样的?

为什么不透明和透明的UINavigationBarAppearance的view.safeAreaInset是一样的?
EN

Stack Overflow用户
提问于 2021-10-05 07:57:44
回答 1查看 35关注 0票数 0

当我们使用使用导航栏上的isTranslucent属性使导航栏变得半透明或不透明的旧方法时,视图的safeAreaInset为半透明导航栏和viceVersa返回非0的值。

但是,当使用下面的代码作为pe新的iOS 13 SDK时,不会出现这种行为。

代码语言:javascript
复制
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。

EN

回答 1

Stack Overflow用户

发布于 2021-10-12 09:53:47

回答我自己的问题:使用isTranslusent和外观API帮助我实现了旧的行为。

As appearance.configureWithOpaqueBackground()只会使条形看起来不透明。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69446744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档