1

iOS 11とswift 4(Xcode 9)をアップグレードした後、UIの問題がたくさんありました。 :(
ほとんど解けない問題は、ナビゲーションの問題である。
私はUICollectionViewコントローラー。
ナビゲーションバーの高さが正しく表示されませんし、私はコードを書くしかし。
swift 4、iOS 11のUICollectionViewにナビゲーションバーを追加

私は、ナビゲーションバーの高さを設定するにはナビゲーションバーを入れて」 100" 。私は(の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) 
    } 

はしかし、私はこのコードを試してみました。何が私のために動作しません。

enter image description here


私はまた、ソースコードビューでストーリーボードを開こうとしたと私は、ナビゲーションバーの高さを編集します。しかし、それはまた動作しません。
誰も私を助けることができますか?私はこの2日間でこの問題を解決しようとしています。

+0

は、私はあなたがナビゲーションバーの高さを調整することができるとは思いません。代わりに、カスタムナビゲーションバーを作成し、システムによって与えられたナビゲーションバーを隠すことができます。 – antonio081014

答えて

0

確認してください:

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) 
} 
+0

私は今この問題を解決することができます。しかし別の問題がありますhttps://stackoverflow.com/questions/46376475/uinavigationbar-does-not-overlap-to-uicollectionview-in-swift-4あなたは私の仲間を助けてくれますか? –

+0

あなたのソリューションは何ですか? @MayPhyu – antonio081014

+0

@ antonio081014、私はこのリンクを参照してくださいhttps://stackoverflow.com/questions/31940352/how-to-increase-the-height-of-navigation-bar-in-xcode私はナビゲーションバーの高さを増やすためのスペースを追加する –

関連する問題