2

After upgrading the iOS 11 and swift 4(Xcode 9), I got lots of UI problem. :(
The most unsolvable problem is Navigation Problem.
I put the Navigation Bar in UICollectionView Controller.
Navigation bar height does not show properly and however I write the code.

I set navigation bar height "100". I write this code in ViewDidLoad().

  if #available(iOS 11.0, *) {

        print("IOS 11 Screen")

        UINavigationBar.appearance().largeTitleTextAttributes = [
            NSForegroundColorAttributeName: UIColor.white,

        ]
        navigationItem.largeTitleDisplayMode = .never
        let height: CGFloat = 100 //whatever height you want
        let bounds = self.navigationController!.navigationBar.bounds
        self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)


    } else {
        print("lower than IOS 11 Screen")
        // Fallback on earlier versions
    }

 collectionview?.frame = CGRect(x: 0, y: 10, width: UIScreen.main.bounds.width, height: (UIScreen.main.bounds.height + 20)) <br>

 override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    let height: CGFloat = 100 //whatever height you want
    let bounds = self.navigationController!.navigationBar.bounds
    self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)

}


override func viewWillAppear(_ animated: Bool) {
        let height: CGFloat = 100 //whatever height you want
        let bounds = self.navigationController!.navigationBar.bounds
        self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
    }

However, I tried with this code. Nothing works for me.

enter image description here


I also tried to open the storyboard with source code view and I edit the height of Navigation bar. But, it also does not work.
Can anyone help me please? I have been trying to solve this problem since last two days.

May Phyu
  • 895
  • 3
  • 23
  • 47
  • I don't think you could adjust the height of Navigation Bar. instead, you could create a custom navigation bar, while cover it up on the one given by system. – antonio081014 Sep 23 '17 at 06:22

1 Answers1

0

Please check :

override func viewDidLoad() {
    if #available(iOS 11.0, *) {
        print("IOS 11 Screen")
        UINavigationBar.appearance().largeTitleTextAttributes = [
            NSForegroundColorAttributeName: UIColor.white,
        ]
        self.navigationController?.navigationBar.prefersLargeTitles = true // added this line
        navigationItem.largeTitleDisplayMode = .never
    } else {
        print("lower than IOS 11 Screen")
        // Fallback on earlier versions
    }
}

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    let height: CGFloat = 100 //whatever height you want
    let bounds = self.navigationController!.navigationBar.bounds
    self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
}
Vini App
  • 7,339
  • 2
  • 26
  • 43
  • I can solve this problem now bro. But I got another problem https://stackoverflow.com/questions/46376475/uinavigationbar-does-not-overlap-to-uicollectionview-in-swift-4 Could you please help me bro? – May Phyu Sep 23 '17 at 06:15
  • What's your solution? @MayPhyu – antonio081014 Sep 23 '17 at 06:22
  • @antonio081014, I refer this link https://stackoverflow.com/questions/31940352/how-to-increase-the-height-of-navigation-bar-in-xcode. I add space to increase the height of Navigation bar bro – May Phyu Sep 23 '17 at 06:27
  • Yes bro @antonio081014, I got another problem bro https://stackoverflow.com/questions/46376475/uinavigationbar-does-not-overlap-to-uicollectionview-in-swift-4 . Could you please take a look at? – May Phyu Sep 23 '17 at 06:31