问题标签 [uinavigationbarappearance]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
swiftui - 在 SwiftUI 中切换 UINavigationBar 外观
我需要能够按需更改 SwiftUI 视图中的颜色。这不是根据需要为视图中的对象切换颜色的问题,但是如何为 NavigationBar 外观属性做到这一点?这是我在视图初始化时设置导航栏外观的方法。点击按钮会更改按钮颜色,但不会更改导航栏的外观。使用不同的 theme1 值重新启动应用程序将显示正确的颜色,但点击按钮只会更改按钮颜色,而不会更改 NavBar 的外观。
}
swift - 为什么我的 NavigationBar 颜色在 Swift 中没有改变?
我做了一个自定义NavigationBar
以在所有屏幕上使用,如下所示:
并像这样打电话SignupVC ViewWillAppear
:
使用上面的代码,我没有得到黄色NavigationBar
。我NavigationBar
像唯一的白色一样进入 SignupVC。没有leftbutton
菜单。为什么?我哪里错了?
谢谢你。
xcode - 由 Xcode 版本 13 构建的应用程序在 ios 12 上崩溃
我的应用在 iOS 15 和 14 上运行良好,也许 13 也是。但是当我在使用 iOS 12 的旧设备上运行时,它在启动时崩溃,甚至在触发 didFinishLaunchingWithOptions 之前。上次我使用 Xcode 12 构建时它运行良好。
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named UINavigationBarAppearance because no class named UINavigationBarAppearance was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)' terminating with uncaught exception of type NSException
ios - 从 iOS 15 上的非透明导航栏导航到具有透明导航栏的视图控制器
在 iOS 15 上,当导航到具有透明导航栏的视图控制器时,透明栏的动画无法按预期工作。
但是,如果您使用透明导航栏导航回视图控制器,动画将按预期工作。
这就是我设置视图控制器的方式:
根VC
第一VC
第二个VC
请注意,在以下示例中,从secondVC -> firstVC但不是从rootVC -> firstVC过渡是多么平滑:
示例项目:https ://github.com/karlingen/NavigationTest
任何想法为什么它会这样?
uinavigationbar - 为什么不透明和透明 UINavigationBarAppearance 的 view.safeAreaInset 相同?
当我们使用导航栏isTranslucent
上的属性使导航栏半透明或不透明的旧方法时,视图的 safeAreaInset 为半透明导航栏返回一些不是 0 的值,反之亦然。
但是当使用下面的代码作为 pe new iOS 13 SDK 时,看不到这种行为
对于此代码,我仍然看到 safeAreaInset.top > 0。
请帮助我理解这种行为。以及如何使用新的 UINavigationBarAppearance api 将 inset.top 设为 0。
swift - 使用 MVVM+C 更改 UINavigaitonBar 的后退按钮
我正在使用 MVVM+C 模式来构建我的应用程序。目前,我面临将导航栏的本机后退按钮标题和图像更改为没有标题的自定义图像的问题。我已经尝试了很多我能找到的解决方案,但没有设置不同的标题甚至图像。我在 AppDelegate.swift 中得到了这段代码:
另外,我遵循了官方文档,但没有任何成功。默认情况下,我已将导航栏设置为隐藏(因为多次不需要),我将其显示ViewWillAppear
并隐藏在ViewWillDisappear
方法中。
有人知道发生了什么吗?谢谢!
解决方案: 使用 Scott 的代码后,我能够更改导航栏的图像和外观,但我失去了向后滑动的能力。将此代码添加到 UINavigationBar 扩展后,我能够将其取回: