- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个 FirstViewController
和一个 SecondViewController
。它们的 UINavigationBar
有不同的颜色。当我显示 SecondViewController
时,颜色逐渐淡化。我用模拟器和慢动画录制了动画。
但是,当我从 SecondViewController
返回到 FirstViewController
时,颜色没有动画,一切都立即改变。
这就是我在 SecondViewController
中为 UINavigationBar
设置代码的方式。
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let navBar = self.navigationController?.navigationBar {
navBar.barStyle = UIBarStyle.black
navBar.barTintColor = NavBarColor.red
navBar.backgroundColor = NavBarColor.red
navBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
navBar.isTranslucent = false
navBar.tintColor = .white
}
}
在我的FirstViewController
类中,我创建了一个结构NavBarSettings
并保存了UINavigationBar 的信息。然后我在 viewWillAppear
中应用它们。
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let navBar = self.navigationController?.navigationBar,
let navBarSettings = self.navBarSettings {
navBar.barStyle = navBarSettings.barStyle
navBar.barTintColor = navBarSettings.barTintColor
navBar.backgroundColor = navBarSettings.backgroundColor
navBar.titleTextAttributes = navBarSettings.titleTextAttributes
navBar.isTranslucent = navBarSettings.isTranslucent
navBar.tintColor = navBarSettings.tintColor
}
}
我也尝试在 SecondViewController
viewWillDisappear
中更改 UINavigationBar 信息,但它具有相同的效果。
我也尝试设置一个 backgroundColor
但它也没有改变任何东西。
如何让第二个动画像第一个一样工作?
更新
到 SecondViewController
的转场很好看。
我只是用 self.performSegue(withIdentifier: "SecondViewControllerSegue", sender: nil)
我没有向后退按钮添加任何自定义代码,它是默认的 UINavigationController
实现。
最佳答案
尝试用自定义后退按钮替换后退按钮并向其添加操作。
let backButton = UIButton()
backButton.addTarget(self, action: #selector(self.backButtonClicked), for: UIControlEvents.touchUpInside)
navBar.navigationItem.leftBarButtonItem = barButton
func backButtonClicked() {
// try implementing the same thing here but with the self.navigationController?.popViewController(animated: true)
}
关于ios - 解除 UIViewController 时 UINavigationBar 奇怪的颜色变化动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42271324/
我有一个带有导航栏的 viewController。我想增加导航栏的高度,但我不能。我已经在寻找增加导航栏高度的方法,但没有成功。 是否有任何增加导航栏或任何其他 lib/alternatives 的
是否可以在左侧或右侧放置自定义图像 UIBarButton 项 边缘一个 UINavigationBar?如果按钮的边缘接触 UINavigationBar 的边缘,我创建按钮的方式看起来最好。 最佳
我喜欢将我的 View 创建为独立的 Xib 文件,然后实例化它们并添加为 subview 。 因此,当使用 UINavigationBar 时,我希望能够做同样的事情,首先创建我的自定义 View
我正在创建一个 iOS 7 应用程序,其中我希望在 NavigationBar 下方有一个 SearchBar,我希望它们看起来像一个整体。因此,我需要用相同的颜色(已经完成)为它们着色,并删除 Na
我有一些UIViewControllers,它们都有纯背景颜色。但是,在用户的个人资料上,我想在背景上显示模糊的个人资料图像,因此我需要一个透明的 UINavigationBar。这很好用。我的做法如
更改 UINavigationBar 背景图像并使主 UINavigationBar 缩放到背景图像大小的最简单方法是什么? 我设计了一个导航栏,它不是我的 TableView Controller
我正在创建一个 iOS 7 应用程序,我希望在其中的 NavigationBar 下方有一个 SearchBar,并且我希望它们看起来像一个整体。因此,我需要用相同的颜色(已经完成)给它们着色,并删除
我需要将导航栏设置为自定义颜色,下面的代码将执行此操作: [[UINavigationBar appearance] setBackgroundImage:navigation
我添加了带有背景图片的 UINavigation 栏。 但不幸的是,UINavigation Bar 中间显示了一条不需要的 1px 细线。 我想隐藏那条线,但它不起作用。我添加了以下代码。 self
我有一个简单的应用程序,它是一个 UITableViewController。该应用程序使用自定义主题,将主题应用于背景和 UINavigationBar。从这个角度来看,我有一个 UINavigat
我在我的名为 BaseViewController 的 Superview 中以编程方式添加了 UINavigationBar,它继承了 UIViewController。但是当我尝试为 UINavi
我正在开发一个具有多个嵌套 UIViewController 的应用程序。我有两个 View ,一个是带有 uibarbuttonitem 的 Root View Controller ,连接到另一个
我知道我可以单独更改导航栏的字体,如以下答案所述:Change the navigation bar's font 目前我正在使用更全局的方法: //in my app delegate: [
我正在尝试从 Tinder 重新创建导航行为。为此,我翻译了一个 Framework delivering the NavigationBar进入 Swift 3。 测试应用程序非常简单。我创建了一个
我能否以某种方式使 UINavigationBar 在 iOS 7 和 iOS 8 中看起来像 iOS 6 UINavigationBar(具有蓝色背景颜色等)? 提前致谢。 最佳答案 我很惭愧地承认
在我的iPad应用程序中,我有一个应用程序设置 View 。选项之一允许用户切换界面颜色方案。通过segue将设置 View 加载到与“主”应用程序窗口不同的单独 View Controller 中。
我制作了一个自定义的 UIStoryboardSegue 但当它展开时,它似乎导致我的 UINavigationBar 变黑,然后又恢复到正确的颜色。请参阅下面的 GIF。 我的自定义segue只是让
下面的代码对我不起作用,任何人都可以帮助找出问题所在吗? var image = UIImage(named: "10384605_10152519403846670_5189785375955620
我想更改导航标题的字体和颜色..所以,为此我已经在下面的代码中完成了这个......但它不起作用...... if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@
我对iOS 7有一些奇怪的麻烦。我的应用程序中有一个UINavigationBar,它非常适合iOS 6; - IOS 6 - 但是,当我尝试在iOS 7上运行它时,后退按钮消失了。它在那里,仍在工作
我是一名优秀的程序员,十分优秀!