ios – The way to change top of navigation bar and objects measurement?


I need to create navigation controller and navigation bar programatically. I need to change top and objects measurement and place. My navigation bar top = 74 and merchandise measurement = 50×50. Additionally merchandise high area = 12 and backside = 12. I attempting to do it with this code:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, choices connectionOptions: UIScene.ConnectionOptions) {
    if let windowScene = (scene as? UIWindowScene) {
        let window = UIWindow(windowScene: windowScene)
        let navigationController = UINavigationController()
        let viewController = ViewController()
        navigationController.viewControllers = [viewController]
        window.rootViewController = navigationController
        self.window = window
        window.makeKeyAndVisible()
    }
}

ViewController

override func viewDidAppear(_ animated: Bool) {
        tremendous.viewDidAppear(animated)
        
        self.navigationController?.navigationBar.backgroundColor = .grey
        self.navigationController?.navigationBar.body.measurement.top = 74
        navigationItem.backBarButtonItem = UIBarButtonItem(title: "", model: .plain, goal: nil, motion: nil)
        
        let menuBtn = UIButton(sort: .customized)
        menuBtn.body = CGRect(x: 0.0, y: 12.0, width: 50, top: 50)
        menuBtn.setImage(UIImage(named:"mute"), for: .regular)

        let menuBarItem = UIBarButtonItem(customView: menuBtn)
        menuBarItem.customView?.widthAnchor.constraint(equalToConstant: 50).isActive = true
        menuBarItem.customView?.heightAnchor.constraint(equalToConstant: 50).isActive = true
        menuBarItem.setBackgroundVerticalPositionAdjustment(12.0, for: .default)
        self.navigationItem.rightBarButtonItem = menuBarItem
    }

Nevertheless it does not work. I do not see the peak of the navigation bar modified, nor the dimensions and place of the navigation buttons. The way to clear up an issue?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles