Kus*_*jee 2 uinavigationbar ios swift ios13
代码:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UINavigationBar.appearance().barTintColor = .red
return true
}
Run Code Online (Sandbox Code Playgroud)
如果 prefersLargetitles 为 false 则没有问题。但是使用prefersLargeTitles = true,颜色不会改变。这曾经适用于 iOS 12。但由于 iOS 13 这不起作用。任何人都可以帮助如何在 iOS 13 中自定义导航栏
iOS 13 中导航栏外观有一些变化,默认情况下,如果关联视图控制器具有可滚动内容,导航栏将变为透明。
在这种情况下,您应该创建一个UINavigationBarAppearance对象并将其分配给compactAppearance和scrollEdgeAppearance。您也可以更改UINavigationBarAppearance对象的属性。
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = .purple
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
} else {
UINavigationBar.appearance().barTintColor = .purple
}
Run Code Online (Sandbox Code Playgroud)
您可以在此处和iOS13release_notes 中找到更多详细信息
| 归档时间: |
|
| 查看次数: |
306 次 |
| 最近记录: |