gpt4 book ai didi

swiftui - 如何在 SwiftUI 中制作半透明导航栏?

转载 作者:行者123 更新时间:2023-12-04 04:30:53 25 4
gpt4 key购买 nike

我看过几篇讨论如何在 SwiftUI 中制作透明导航栏的帖子,但没有关于如何制作半透明导航栏,这让我感到惊讶,因为它是 Apple 默认应用程序中非常常见的模式。例如笔记应用程序:
enter image description here
您可以通过导航栏查看绘图。任何人都知道如何做到这一点,最好是在明/暗模式下工作?

最佳答案

也许您只需要在 SwiftUI View 中添加半透明设置
demo1

init() {
UINavigationBar.appearance().isTranslucent = true
}
替代是完全重置外观,例如
demo2
init() {
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.backgroundColor = UIColor.systemBackground.withAlphaComponent(0.5)
UINavigationBar.appearance().standardAppearance = appearance
}
使用 Xcode 12/iOS 14 准备和测试的演示

关于swiftui - 如何在 SwiftUI 中制作半透明导航栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64074260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com