Changing the height of the Navigation bar iOS Swift

前端 未结 3 1993
忘掉有多难
忘掉有多难 2020-11-27 21:40

I am trying to change the height of there navigation bar for my app. Currently the height is fixed to 44. I can change the width from Xcode but not the height.

I ha

3条回答
  •  时光说笑
    2020-11-27 22:38

    Try this :

    import UIKit
    
    class YourViewController : UIViewController {
    
        var navBar: UINavigationBar = UINavigationBar()
    
        override func viewDidLoad() {
            super.viewDidLoad()
            self.setNavBarToTheView()
            // Do any additional setup after loading the view.
            self.title = "test test"
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
        func setNavBarToTheView() {
            self.navBar.frame = CGRectMake(0, 0, 320, 50)  // Here you can set you Width and Height for your navBar
            self.navBar.backgroundColor = (UIColor.blackColor())
            self.view.addSubview(navBar)
        }
    }
    

提交回复
热议问题