Adding a navigation bar to a tab-based application

I have a tab-based application and I want to add a navigation bar at the top of the application. Note that I am using a library called PageMenu , which creates 2 table elements inside 1 of the parent ViewController.

I tried adding a new ViewController and Editor-> Embed to the navigation bar. Place it in front of the controller of the tab bar, ctrl + drag it to the tab bar to set the relation of the root view. Finally, set the Nav Bar Controller as the initial controller. But this is not so:

enter image description here

(Top got pretty weird, blurry, and the subtitle of the Menu page disappeared. Maybe it's under that blurry thing, because I can still draw between the two table views.

enter image description here

Secondly, I tried to remove the navigation controller and manually add the navigation bar to the ViewControllers. This worked for table view and view controllers, but not for the PageMenu parameter. When I tried it on PageMenu Controller, it did not show the navigation bar.

Note that in demo mode, they used the navigation bar as the parent and sub-TableViews, and they reached the navigation bar with this, as well as using the storyboard> navigation controller:

override func viewDidLoad() {
    super.viewDidLoad()

    self.title = "HEADER"
    self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
    self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
  }

Finally, I tried ..

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

    let nav1 = UINavigationController()
    let first = ViewController(nibName: nil, bundle: nil)
    nav1.viewControllers = [first]

    let second = SecondViewController(nibName: "SecondViewController", bundle: nil)
    let nav2 = UINavigationController()
    nav2.viewControllers = [second]

    let tabs = UITabBarController()
    tabs.viewControllers = [nav1, nav2]

    self.window!.rootViewController = tabs;
    self.window?.makeKeyAndVisible();

    return true
}

But I get the result:

enter image description here

What I want to achieve (but with TabBarController, NavBar for title only):

enter image description here

. NavigationBar , PageMenu

enter image description here


Update: , : enter image description here

: enter image description here

+4
2

, .

enter image description here

, , , .

.

+6

Check this image

- > add Editor- > " ", .

Tab Vise, - > View.

+3

Source: https://habr.com/ru/post/1618560/


All Articles