- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
问题
我有一个应用程序,它为不同的流程提供不同颜色的导航栏。一些导航栏有浅色背景,需要黑色状态栏文本。其他的导航栏较暗,需要白色的状态栏文本。
作为迁移到 iOS15 的一部分,我更新了我正在开发的应用程序以使用 UINavigationBarAppearance
导航栏样式的方法。
除了状态栏颜色之外,我可以像以前一样设置所有样式。
以前我一直在使用barStyle
导航栏上的属性设置状态栏文本颜色。
navigationBar.barStyle = .black
这在使用
UINavigationBarAppearance
时似乎不起作用.
override func viewDidLoad() {
super.viewDidLoad()
let navigationBar = navigationController?.navigationBar
// Style using old approach
navigationBar?.barTintColor = UIColor.purple
navigationBar?.titleTextAttributes = [.foregroundColor: UIColor.white]
// Use barStyle to set status bar text color to white
// This only work when using the old styling approach
navigationBar?.barStyle = .black
}
override func viewDidLoad() {
super.viewDidLoad()
let navigationBar = navigationController?.navigationBar
// Style nav bar using new Appearance API
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.backgroundColor = UIColor.purple
navBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]
navigationBar?.standardAppearance = navBarAppearance
navigationBar?.scrollEdgeAppearance = navBarAppearance
// Use barStyle to set status bar text color to white
// This only work when using the old styling approach
navigationBar?.barStyle = .black
}
overrideUserInterfaceStyle
将状态栏文本设置为白色。 .要使状态栏文本变白,请设置
navigationBar.overrideUserInterfaceStyle = dark
但是,这会导致导航栏中按钮的菜单也处于黑暗模式,这不是我想要的。
preferredStatusBarStyle
强制使用黑色或白色文本。
最佳答案
我能够使用以下方法将状态栏文本设置为白色:
navController.navigationBar.overrideUserInterfaceStyle = .dark
请注意,此问题的创建者 Bencallis 警告说,此解决方案“导致导航栏中按钮的菜单也处于黑暗模式,这不是我想要的”。我不使用这样的菜单,所以这对我来说不是问题。也许它也不适合你。
关于iOS:使用 UINavigationBarAppearance 时指定状态栏文本颜色现在 barstyle 被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69404806/
我有一个显示导航 Controller 的模态视图 Controller 。导航 Controller 反过来有一个常规的 UIViewController 作为它的 Root View Contro
我正在为 NavigationBar 应用新的外观 API,但我正在努力处理状态栏内容(文本)。在 Info.plist 上,我强制使用浅色模式,因为大多数应用程序是白色的,但在我的一个 viewCo
很确定这是一个内存相关的问题,但它总是发生在同一个地方,当我将一个新 Controller 推到导航 Controller 堆栈上时 CurrentActivityViewController *co
我找遍了所有地方,但似乎找不到有效的解决方案... 我正在开发一个应用程序,它使用 MPMediaPickerController 并创建一个模态视图,允许用户选择要播放的歌曲。我的主视图有一个 bl
问题 我有一个应用程序,它为不同的流程提供不同颜色的导航栏。一些导航栏有浅色背景,需要黑色状态栏文本。其他的导航栏较暗,需要白色的状态栏文本。 作为迁移到 iOS15 的一部分,我更新了我正在开发的应
我正在尝试使状态栏的 barStyle 动画化,这样当我滚动时,我可以将 barStyle 类型从 'dark-content' 更改为 'light-content' . 首先,我制作了我的状态栏动
我正在尝试使状态栏的 barStyle 动画化,这样当我滚动时,我可以将 barStyle 类型从 'dark-content' 更改为 'light-content' . 首先,我制作了我的状态栏动
渐变被错误地使用 StartColor 和 Color 绘制。它不考虑 EndColor 的值。 Bar bar = new Bar(); bar.setMultiBar(MultiBars.STAC
我正在使用以下代码为我的 UINavigationBar 和 UIToolbar 设置自定义图像: [[UINavigationBar appearance] setBackgroundImage:[
我有一个自定义颜色导航栏,我需要确保状态栏颜色设置为白色。在 iOS 13 之前,这很容易做到,这是 UIViewController 中的一个代码片段,它可以很好地完成这项工作: override
我的项目中有一个 navigationBar 和工具栏在同一个 View Controller 中运行。我在 Swift 2 中使用 barStyle 自定义导航和工具栏的外观,如下所示: overr
我正在尝试将 iOS7 的标签栏 Controller 的颜色设置为黑色。除了 morenavigationcontroller 之外,所有 View Controller 都是深黑色。 morena
在使用 setBackgroundImage:forBarMetrics 设置 UINavigationBar 样式后,我尝试使用 UIBarStyleBlackTranslucent。 这里的问题是
statusBar的barStyle="dark-content"在Android 5上不起作用,但在Android 6上可以很好地工作。 这是代码: import React, { Componen
我是一名优秀的程序员,十分优秀!