Pom*_*ule 14 uinavigationcontroller ios swift swiftui
使用 SwiftUI 如何更改导航栏的标题大小?在标准或大标题之间进行选择。
Pom*_*ule 28
SwiftUInavigationBarTitle
修饰符有一个可选displayMode
属性,您可以将其设置为小标题.inline
和.large
大标题。查看文档
NavigationView {
TopLevelView {
// […]
}
.navigationBarTitle("Test", displayMode: .inline) // ?? Important part
}
Run Code Online (Sandbox Code Playgroud)
从 iOS 11 开始,UINavigationBar
可以在标准和大标题模式下显示其标题。
在UIKit 上,如果你想在这两种行为之间进行选择,你必须设置largeTitleDisplayMode
你的 ViewController 的属性navigationItem
来决定这个特定的视图控制器是否应该显示一个大标题。
然后,您需要检查prefersLargeTitle
导航控制器的navigationBar
. 将其设置为true
将允许其导航堆栈中的 ViewController 显示大标题。相反,将其设置为false
将阻止它,覆盖堆栈中存在的各个 NavigationItems 的首选项。
这将在 UIKit 中显示一个大标题
// Set this property to true to allow NavigationItems to display large titles
let navigationController = UINavigationController()
navigationController.navigationBar.prefersLargeTitles = true
/*
Choose between `always`, `never` and `automatic` to decide
if this particular view controller should display a large title.
*/
let viewController = UIViewController()
viewController.navigationItem.largeTitleDisplayMode = .always
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11604 次 |
最近记录: |