iOS:删除UINavigationBar动画 [英] iOS: Removing UINavigationBar animation

查看:117
本文介绍了iOS:删除UINavigationBar动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序具有一个UINavigationBar,上面带有图像.当我们选择(推送)到另一个屏幕,然后单击后退"按钮时,导航栏上的图像似乎会从左到右进行动画处理.这有点分心.如何删除此后退按钮动画?

Our app has an UINavigationBar with an image on it. When we segue (push) to another screen then click the back button the image on the Navigation Bar seems to animate from left to right as it reappears. This is a little distracting. How can you remove this back button animation?

我们尝试更改segue Animates设置,但这同时更改了推动画和后动画.

We tried changing the segue Animates setting but this changes both the push animation and not the back animation.

我们的导航条形码:

    let logoImage:UIImage = UIImage(named: "ABC")!
    viewController.navigationItem.titleView = UIImageView(image: logoImage)

推荐答案

在很大程度上归因于此答案 https://stackoverflow.com/a/8602982/47281

Figured this out in large part due to this answer https://stackoverflow.com/a/8602982/47281

创建自定义导航栏并覆盖popItem:

Create a custom Nav Bar and override popItem:

class MyNavigationBar: UINavigationBar {
    override func popItem(animated: Bool) -> UINavigationItem? {
        return super.popItem(animated: false)
    }
}

通过情节提要板输入MyNavigationBar作为导航控制器的导航栏类:

Entered MyNavigationBar as the Navigation Bar class for our Navigation Controller via the Storyboard:

请注意,我没有像链接答案中那样覆盖NavigationController popViewControllerAnimated.

Note I did not override NavigationController popViewControllerAnimated as in the linked answer.

这篇关于iOS:删除UINavigationBar动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆