Left/RightBarButton is always in the middle

Hey,

 

I am trying to build a custom navigation bar. When I set the navigationItem to leftbarbutton/rightbarbutton everything is working fine but the hamburger button is still in the middle. How can I solve this problem ?

 

I used this Tutorial: https://www.youtube.com/watch?v=dB-vB9uDRCI&t=381s

 

Thank you for helping

 

import UIKit

 

class HomeController: UIViewController

{

    override func viewDidLoad()

    {

        super.viewDidLoad()

     

        view.backgroundColor = .white

        configureNavigationBar()

    }

 

 

 

    @objc func  handleMenuToggle()

    {

        print(“toggle hat funktioniert”)

    }

 

    func configureNavigationBar()

    {

        navigationController?.navigationBar.barTintColor = .darkGray

        navigationController?.navigationBar.barStyle = .black

     

        navigationItem.title = “Side Button”

        navigationItem.leftBarButtonItem = UIBarButtonItem(image:  imageLiteral(resourceName: “hamburgerIcon2”).withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(handleMenuToggle))

    }

 

}

Powered by WPeMatico

You may also like...

Comments are closed.