SwiftUI 状态栏设置:隐藏和颜色

SwiftUI 状态栏设置:隐藏和颜色,第1张

前言
xcode 13.3
iOS 15.4
1、状态栏隐藏和显示

/// Sets the visibility of the status bar.
/// Use statusBar(hidden:) to show or hide the status bar.
/// - Parameter hidden: A Boolean value that indicates whether to hide the status bar.
/// 设置状态栏的可见性。
/// 使用 “状态栏(隐藏:)” 显示或隐藏状态栏。
///- 参数隐藏:一个布尔值,指示是否隐藏状态栏。

.statusBar(hidden: true) 
2、状态栏的颜色设置

/// The color scheme that corresponds to a light appearance.
/// 与灯光外观相对应的配色方案。
case light
/// The color scheme that corresponds to a dark appearance.
/// 与深色外观相对应的配色方案。
case dark

dark 会把状态栏颜色变为白色,但同时也会把你的背景变成黑色!无论你是否设置 Appearance 为 Light

.preferredColorScheme(.dark)

此处设置会导致全局变成暗黑模式,暂时尚未找到更好的方法,找到后会更新

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/996790.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存