Replacing UINavigationControllers NavigationBar with UIView

后端 未结 2 1730
情书的邮戳
情书的邮戳 2021-01-23 22:21

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

One of the solutions would be to have separate nib files for every skin, and lo

2条回答
  •  盖世英雄少女心
    2021-01-23 23:15

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

    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.

    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.

    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.

    EDIT:

    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.

提交回复
热议问题