用UIView替换UINavigationControllers NavigationBar [英] Replacing UINavigationControllers NavigationBar with UIView

查看:200
本文介绍了用UIView替换UINavigationControllers NavigationBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发具有多个皮肤的应用程序,我对如何实现这个问题感到困惑。

I am developing app that has multiple skins and I have a dilema on how to implement this.

其中一个解决方案是为每个人提供单独的nib文件皮肤,并根据目前选择的皮肤加载它。问题是我无法编辑导航控制器的导航栏(我的应用程序使用),我必须更改它的背景图像和后退按钮图像等。我想出了一个想法,隐藏每个导航栏屏幕并用Interface Builder中的自定义UIView替换它,它将充当导航栏和带有IBAction的自定义后退按钮,用于弹出当前的View Controller,这样用户就不会看到任何差异。

One of the solutions would be to have separate nib files for every skin, and load it depending on wich skin is currently selected. Problem with this is that I can't edit navigation bar of navigation controller (wich my app uses), and I have to change it's background image and back button image etc.. I came up with an idea to hide this navigation bar on every screen and replace it with custom UIView in Interface Builder wich will act as navigation bar and custom back button with IBAction for popping current View Controller, so that user won't see any difference.

这种方法是否可以接受,如果我这样做,我会在App Store中拒绝问题吗?

Is this approach acceptable and if I make it this way, will I have problems with rejection in App Store?

推荐答案

如果你选择隐藏&用你自己的UIV替换UINavigationBar就Apple来说没问题。

If you choose to hide & replace the UINavigationBar with your own UIView it's no problem as far as Apple goes.

但是,我可以告诉你,你将不得不花一些时间试图复制一些视觉效果UINavigationBar自然产生的效果。

However, I can tell you that you will have to spend some time trying to replicate some visual effects that come naturally with UINavigationBar.

例如,当您按下/弹出一个新的控制器时,您会看到导航栏标题将滑动&褪色很漂亮。这同样适用于左右栏项目。

For example, when you push/pop a new controller, you will see that the navigation bar title will slide & fade beautifully. The same applies for left and right bar items.

我个人不会完全隐藏UINavigationBar,而是自定义它。最后这一切都取决于你想要什么,但默认情况下UINavigationBar是可定制的。

Personally I would not completely hide the UINavigationBar, but customize it. In the end it all depends on what you want, but by default the UINavigationBar is pretty customizable.

您可以添加自己的按钮甚至整个UIViews作为左右栏项目。此外,您可以添加自己的UIView作为标题(使用您自己的标签,自定义字体或其他)或更改背景。

You can add your own buttons or even entire UIViews as left and right bar items. Also, you can add your own UIView as the title (with your own label, custom font or whatever) or change the background.

编辑:

要轻松自定义整个应用程序中的外观,可以继承UINavigationController并创建自己的CustomUINavigationController。然后,在viewDidLoad方法中,您可以将任何内容更改为导航栏,这将在整个应用程序中可访问。

To easily customize the looks in your entire application, you can subclass UINavigationController and create your own CustomUINavigationController. Then, in viewDidLoad method you can change whatever you want to the navigation bar and this will be accessible in the entire application.

这篇关于用UIView替换UINavigationControllers NavigationBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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